How to calculate a variable dependent on the state variables using ODE?

1 vue (au cours des 30 derniers jours)
Hugo Mendonça
Hugo Mendonça le 2 Juin 2017
Hi, Everyone!
Given a simple state-space system such as:
dx/dt = Ax + Bu
y = Cx + Du
To solve it, I am using the ode fuction because it is more convenient for me and it works fine. For example:
[t,x] = ode23s(@(t,x) system(t,x,A,B,u,ut),tspan,iniCon);
function dx = system(t,x,A,B,u,ut)
u = interp1(ut,u,t);
dx = A*x + B*u;
end
If I insert some simple nonlinearity to this system, it would become:
function dx = system(t,x,A,B,u,ut)
u = interp1(ut,u,t);
if x(1) > threshold
A = A*2;
dx = A*x + B*u;
else
dx = A*x + B*u;
end
and, again, the system works perfect.
If flag is a variable in the time that represents which condition the system is being calcuted, how can I calculate it with the same sample rate of x?
Appreciate any help.

Réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by