ode45を使用して毎時間微分方程式を解かせたい
Show older comments
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 Comment
宇海
on 1 Sep 2023
Accepted Answer
More Answers (1)
宇海
on 4 Sep 2023
0 votes
1 Comment
Aiswarya
on 5 Sep 2023
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 :
Categories
Find more on 常微分方程式 in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!