Euler's method help
古いコメントを表示
I am trying to plot an euler's method for dx/dt=-100x for x(t)=x(0)e^(-100t) with x(0)=1.My code is
x = 1;
h = 0.001;
n_final = 5;
n = 0;
while (n < n_final)
x(n+h) = x(n)+h*(-100*x(n));
n = n+h;
end
plot(x(n), n)
why is my code not working? I want to plot the numerical solution xn vs x.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Mathematics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!