How to calculate a variable dependent on the state variables using ODE?
2 views (last 30 days)
Show older comments
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.
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!