ode45を使用して毎時間微分方程式を解かせたい
显示 更早的评论
2次のODEをシミュレーション中に解きたいと考えています. 自分で離散化すると, 自分の技術知識不足によりかなり不安定な結果になってしまったのでMATLABのode45を使って解きたいと考えています. イメージとしては次のようなコードです.
このコードのcal_aの中でode45を使おうとしたのですが, 「関数または変数が認識されません。」というエラーになりました.
やり方の検討もつかないので教えていただきたいです.
function main
%初期値の設定
%%%%
result_b = cal_b();
while Time(i) < Time_finish
%次の時刻でのAの計算(Bの結果が必要)
[result_a]= cal_a(result_b);
%次の時刻でのBの計算
[result_b] = cal_b();
%次の時刻でのCの計算(A, Bの結果が必要)
pressure_Bubble_next = Bubble_pressure(result_a, result_b);
%値の更新
i = i+1;
end
采纳的回答
更多回答(1 个)
宇海
2023-9-4
0 个投票
1 个评论
Aiswarya
2023-9-5
Yes, the function odefun is a function handle to which you are passing the values of t and y0. It's better to give f directly as expression in the dydt expression. The inputs which can be given to the odefun are timespan, y0 (initial conditions) and some other options, which you can find in the documentation :
类别
在 帮助中心 和 File Exchange 中查找有关 常微分方程式 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!