Getting error in ode 45

1 回表示 (過去 30 日間)
BINAY NAYAK
BINAY NAYAK 2022 年 2 月 28 日
回答済み: Abolfazl Chaman Motlagh 2022 年 2 月 28 日
function dcdt = odefun1(t,c)
dcdt = zeros(3,1);
dcdt(1) = -c(1)+20*c(2);
dcdt(2) = c(1)-40*c(2)+c(3);
dcdt(3) = 20*c(2)-c(3);
[t,c] = ode45(@odefun1,[0 10],[1;0;0]);
plot(t,c(:,1),t,c(:,2),t,c(:,3))
end
  1 件のコメント
BINAY NAYAK
BINAY NAYAK 2022 年 2 月 28 日
Please help me!

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

回答 (1 件)

Abolfazl Chaman Motlagh
Abolfazl Chaman Motlagh 2022 年 2 月 28 日
you put ode45 and plot in your ode function. try this : (all in one script)
[t,c] = ode45(@odefun1,[0 10],[1;0;0]);
plot(t,c(:,1),t,c(:,2),t,c(:,3))
function dcdt = odefun1(t,c)
dcdt = zeros(3,1);
dcdt(1) = -c(1)+20*c(2);
dcdt(2) = c(1)-40*c(2)+c(3);
dcdt(3) = 20*c(2)-c(3);
end

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by