How to calculate a variable dependent on the state variables using ODE?
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!