Solving differential equations involving heaviside function.
3 ビュー (過去 30 日間)
古いコメントを表示
I have a set of differential equations involving heaviside function. I want to solve it numerically using ode45, however on solving I get all values of y as NaN. But the the derivative functions are not NaN. I think something is going wrong inside ode45. Can anyone guide on how to solve ODEs involving heaviside function using ode45? Please give suitable code snippets if possible.
0 件のコメント
回答 (1 件)
Alan Stevens
2020 年 12 月 12 日
Here's a snippet that works, but it would be better if you uploaded your code, as we stand a better chance of solving your problem that way:
tspan = [0 2];
ic = 1;
[t, y] = ode45(@fn, tspan, ic);
plot(t,y),grid
function dydt = fn(t,y)
u = heaviside(t-1);
dydt = -u*y;
end
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!