MATLAB code for stiff differential equation with explicit Euler method

15 ビュー (過去 30 日間)
Shumaila Khan
Shumaila Khan 2017 年 4 月 27 日
コメント済み: Torsten 2017 年 4 月 27 日
I wrote a following program for of 2 differential equations for stiff differential equation with explicit Euler method. But getting the following error. Any idea? because I don't have, I am new at MATLAB.

回答 (1 件)

Torsten
Torsten 2017 年 4 月 27 日
y(n+1) = y(n)+h*f([x(n) y(n)]);
x(n+1) = x(n)+h*g([x(n) y(n)]);
if your ODE system reads
y' = 98x+198y
x' = -99x-199y
Best wishes
Torsten.
  2 件のコメント
Shumaila Khan
Shumaila Khan 2017 年 4 月 27 日
Actually, I am working on autonomous case
Torsten
Torsten 2017 年 4 月 27 日
... and give x and y an initial value x(1) and y(1) before you enter the for-loop:
f=@(y)...;
g=@(x)...;
h=10;
x(1)=2;
y(1)=3;
for n=1:10
v=[x(n) y(n)];
y(n+1)=y(n)+h*f(v);
x(n+1)=x(n)+h*g(v);
end
Best wishes
Torsten.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLinear Algebra についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by