how can i use ode45 to solve the states if one of them is matrix or vector?
1 次查看(过去 30 天)
显示 更早的评论
how can i use ode45 to solve the states if one of them is matrix or vector?
For example , if the state x is scalar, Z is vector (2*1) of states, and P is matrix (2*2) of states %%
states_0=[x0;Z0;P0];
[t,x]=ode45(@derivative,time,states_0);
0 个评论
回答(1 个)
Jan
2016-5-3
You can transform the elements of the states to a vector using reshape or (:). Inside derivative() you can use reshape again to process the arrays again, if this is needed.
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!