# ode

The ode class is an object that will contain all the information to solve a differential equation. This can be the equation of the dynamics, initial condition, or the solution method itself. This class is necessary in order to generalize the optimal control methods used in other packages.

# Example

Let’s see an example of using class ode. For this we will solve a simple example.

Y = sym('y',[2 1]);
U = sym('u',[2 1]);


with these two variables, we can define the equation of the dynamics of the following form

F = [ sin(Y(1)*Y(2)) +    (Y(1)*Y(2)) + U(1)   ; ...
Y(2)        + cos(Y(1)*Y(2)) + U(2) ] ;
%
dynamics = ode(F,Y,U);
dynamics.Condition = [1,-1];
dynamics

Error using ode (line 212)
The value of 'DynamicEquation' is invalid. The Dynamic Equation must be function handle.For Example:
DynamicEquation = @(t,Y,U,Params) A*Y + B*U + t

Error in tpe25ae5f3_9560_4180_a9c5_2f798e3cce54 (line 20)
dynamics = ode(F,Y,U);



You can solve the equations with a single sentence

solve(dynamics)
resume(dynamics)

plot(dynamics)


# Properties

### StateVector

MATLAB Structure that contain the two properties

• Symbolic - Symbolic Vector State [y1 y2 ...]
• Numeric - Numeric solution of the equation. The numeric property only is aviable if previus solve the equation.

Type Default
Struct none

### Control

MATLAB Structure that contain the two properties

• Symbolic - Symbolic Vector State [u1 u2 ...]
• Numeric - matrix Numeric control to solve the equation. $$\dot{Y} = f(t,\dot{Y},U)$$

Type Default
Struct none

### DynamicEquation

MATLAB Structure that contain the two properties

• Symbolic - symbolic function of dynamics equation
• Numeric - function_handle of dynamics equation.

Type Default
Struct none

### Params

Initial State or Final State dependent of property Type

Type Default
double [0 0 0 ...]

### Derivatives

Initial State or Final State dependent of property Type

Type Default
double [0 0 0 ...]

### InitialCondition

Initial State or Final State dependent of property Type

Type Default
double [0 0 0 ...]

### FinalTime

Time final of simulation

Type Default
double 1

### Nt

Time interval of plots. ATTENTION - the solution of ode is obtain by ode45, with adatative step

Type Default
double none

### MassMatrix

Initial State or Final State dependent of property Type

Type Default
double [0 0 0 ...]

### label

Initial State or Final State dependent of property Type

Type Default
double [0 0 0 ...]

### Solver

Initial State or Final State dependent of property Type

Type Default
double [0 0 0 ...]

### SolverParameters

Initial State or Final State dependent of property Type

Type Default
double [0 0 0 ...]

Type Default

### A

A matrix of lineal problems. If this property is empty, so the ode is not lineal. $$\dot{Y} = \textbf{A}Y + BU$$

Type Default
double none

### B

B matrix of lineal problems. If this property is empty, so the ode is not lineal. $$\dot{Y} = AY + \textbf{B}U$$

Type Default
double none

### C

B matrix of lineal problems. If this property is empty, so the ode is not lineal. $$\dot{Y} = AY + \textbf{B}U$$

Type Default
double none

### lineal

This indicator represent the lineal or non-lineal.

Type Default
logical false

### symt

Represent the symbolic time

Type Default
Symbolic t

### tspan

Time grid to plot the solution, and interpolate the control

Type Default
double none

### ControlDimension

Dimension of Control Vector

Type Default
double none

Type Default

Type Default

# Methods

### ode

It is a constructor of the class 'ode', which allows to create an object compatible with all the functionalities of Dycon Toolbox. Example - matlab Y = sym('y',[1 2]) _n U = sym('u',[1 2]) F = @()Y + U; iode = ode(F,Y,U); 

#### Optional Input Parameters

Name Description class
DynamicEquation Function Handle that give a double with dimension of StateVEctor return the values of the dynamics. function_handle
StateVector Symbolic State Vector. This can be every simbolical vector. sym
Control Symbolic Control Vector. This can be every symbolical vector, but must be different from sym of VectorState Symbolic
A Matrix dynamics. Creating linear problems through this input will make the symbolic calculations faster, in addition to having access to the solver @euleri. matrix
B simbolic expresion matrix
InitialControl matrix double

#### Optional Input Parameters

Name Description class
obj object ode ode

### eulere

The ode class, if only de organization of ode. The solve of this class is the RK family.

#### Optional Input Parameters

Name Description class
DynamicEquation simbolic expresion Symbolic
StateVector StateVector Symbolic
Control simbolic expresion Symbolic
A simbolic expresion matrix
B simbolic expresion matrix
InitialControl matrix double

### euleri

The ode class, if only de organization of ode. The solve of this class is the RK family.

#### Optional Input Parameters

Name Description class
DynamicEquation simbolic expresion Symbolic
StateVector StateVector Symbolic
Control simbolic expresion Symbolic
A simbolic expresion matrix
B simbolic expresion matrix
InitialControl matrix double

### GetSymbolicalDerivativeControl

The ode class, if only de organization of ode. The solve of this class is the RK family.

#### Optional Input Parameters

Name Description class
DynamicEquation simbolic expresion Symbolic
StateVector StateVector Symbolic
Control simbolic expresion Symbolic
A simbolic expresion matrix
B simbolic expresion matrix
InitialControl matrix double

### GetSymbolicalDerivativeState

The ode class, if only de organization of ode. The solve of this class is the RK family.

#### Optional Input Parameters

Name Description class
DynamicEquation simbolic expresion Symbolic
StateVector StateVector Symbolic
Control simbolic expresion Symbolic
A simbolic expresion matrix
B simbolic expresion matrix
InitialControl matrix double

### GetSymbolicalDynamics

The ode class, if only de organization of ode. The solve of this class is the RK family.

#### Optional Input Parameters

Name Description class
DynamicEquation simbolic expresion Symbolic
StateVector StateVector Symbolic
Control simbolic expresion Symbolic
A simbolic expresion matrix
B simbolic expresion matrix
InitialControl matrix double

### GetSymCrossDerivatives

The ode class, if only de organization of ode. The solve of this class is the RK family.

#### Optional Input Parameters

Name Description class
DynamicEquation simbolic expresion Symbolic
StateVector StateVector Symbolic
Control simbolic expresion Symbolic
A simbolic expresion matrix
B simbolic expresion matrix
InitialControl matrix double

### ode113

The ode class, if only de organization of ode. The solve of this class is the RK family.

#### Optional Input Parameters

Name Description class
DynamicEquation simbolic expresion Symbolic
StateVector StateVector Symbolic
Control simbolic expresion Symbolic
A simbolic expresion matrix
B simbolic expresion matrix
InitialControl matrix double

### ode23

The ode class, if only de organization of ode. The solve of this class is the RK family.

#### Optional Input Parameters

Name Description class
DynamicEquation simbolic expresion Symbolic
StateVector StateVector Symbolic
Control simbolic expresion Symbolic
A simbolic expresion matrix
B simbolic expresion matrix
InitialControl matrix double

### ode23tb

The ode class, if only de organization of ode. The solve of this class is the RK family.

#### Optional Input Parameters

Name Description class
DynamicEquation simbolic expresion Symbolic
StateVector StateVector Symbolic
Control simbolic expresion Symbolic
A simbolic expresion matrix
B simbolic expresion matrix
InitialControl matrix double

### ode45

The ode class, if only de organization of ode. The solve of this class is the RK family.

#### Optional Input Parameters

Name Description class
DynamicEquation simbolic expresion Symbolic
StateVector StateVector Symbolic
Control simbolic expresion Symbolic
A simbolic expresion matrix
B simbolic expresion matrix
InitialControl matrix double

### plot

The ode class, if only de organization of ode. The solve of this class is the RK family.

#### Optional Input Parameters

Name Description class
DynamicEquation simbolic expresion Symbolic
StateVector StateVector Symbolic
Control simbolic expresion Symbolic
A simbolic expresion matrix
B simbolic expresion matrix
InitialControl matrix double

### plotT

The ode class, if only de organization of ode. The solve of this class is the RK family.

#### Optional Input Parameters

Name Description class
DynamicEquation simbolic expresion Symbolic
StateVector StateVector Symbolic
Control simbolic expresion Symbolic
A simbolic expresion matrix
B simbolic expresion matrix
InitialControl matrix double

### resume

The ode class, if only de organization of ode. The solve of this class is the RK family.

#### Optional Input Parameters

Name Description class
DynamicEquation simbolic expresion Symbolic
StateVector StateVector Symbolic
Control simbolic expresion Symbolic
A simbolic expresion matrix
B simbolic expresion matrix
InitialControl matrix double

### rk4

The ode class, if only de organization of ode. The solve of this class is the RK family.

#### Optional Input Parameters

Name Description class
DynamicEquation simbolic expresion Symbolic
StateVector StateVector Symbolic
Control simbolic expresion Symbolic
A simbolic expresion matrix
B simbolic expresion matrix
InitialControl matrix double

### solve

The ode class, if only de organization of ode. The solve of this class is the RK family.

#### Optional Input Parameters

Name Description class
DynamicEquation simbolic expresion Symbolic
StateVector StateVector Symbolic
Control simbolic expresion Symbolic
A simbolic expresion matrix
B simbolic expresion matrix
InitialControl matrix double