The graph for the ODE45 function does not work
1 回表示 (過去 30 日間)
古いコメントを表示
The ODE 45 fuction for the second order derivative does not work, because the plot keeps ocilating and i have done a second method and it does not ocilates. How can i fix it?
edit:
The equation i am trying to solve is :
second derivative of delta_h + (Kc/A) * first derivative of delta_h + (Kc/(A*t1)) * delta_h = 0 %with Kc, A and t1 being constants
with initial conditions:
first derivative of delta_h(0) = 2 , delta_h(0) =0
i have added the other code for comparison. In this code the same fuction reaches zero very quickly and without ocilations. I dont know why they are not similar.
1 件のコメント
HWIK
2022 年 1 月 16 日
Your question is a bit abstract, mind providing the problem you are trying to solve?
Because all you have said is that your code doesn't work, because it oscillates, and it is not supposed to. Not a great starting point for others to help
採用された回答
HWIK
2022 年 1 月 16 日
I think the script where you use ode45 is correct, because I don't see any errors there, and using a different method I get the same reult:
Kc = 1;
A = 2;
t1 = 0.1;
syms h(t)
dh = diff(h);
ode = diff(h,t,2) + Kc/A*dh + Kc/A/t1*h == 0;
cond1 = h(0) == 0;
cond2 = dh(0) == 2;
conds = [cond1, cond2];
hSol(t) = dsolve(ode,conds);
fplot(hSol)
Perhaps the mistake is in the coursework_2.m script, but I am not sure what method you are using there to solve the ODE, so can't really help with that.
その他の回答 (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!