Solving as ODE45 and ODE15s gives different results
8 ビュー (過去 30 日間)
古いコメントを表示
Hi, I have to solve this problem

as it were a DAE (I know I could just substitute h into the equation, but this is just an example, because in reality the problem I have to solve is a DAE and more complex than this). When I use ode45 and treat the problem as a second order differential equation, the graph t Vs y is

but when I treat it as a DAE, the graph is completely different

and I do not understand why. Here is my code:
ode45 second order differential equation
function yp = dae_normale(t,y)
yp = zeros(2,1);
yp(1) = y(2);
yp(2) = 4*y(2) + 1/(5*y(2) - 2*y(1) ) - 7*y(1);
ode45 second order differential equation run
[t,y] = ode45('dae_normale',[1,5],[1,1]);
[t,y(:,1)]
plot(t,y(:,1))
DAE ode15s
function out = dae(t,y)
out = [y(2)
4*y(2) + 1/y(3) - 7*y(1)
y(3) - 5*y(2) + 2*y(1) ];
DAE ode15s run
y0 = [1; 1; 3];
M = [1 0 0; 0 1 0; 0 0 0];
options = odeset('Mass',M);
[t,y] = ode15s(@dae,[1 5],y0,options);
[t,y(:,1)]
plot(t,y(:,1))
Thank you.
3 件のコメント
Torsten
2016 年 11 月 10 日
Maybe you should try what happens when you strengthen the tolerances for ODE45 in the options structure (RelTol=1e-8, AbsTol=1e-8).
Best wishes
Torsten.
回答 (1 件)
参考
カテゴリ
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!