フィルターのクリア

ODE code is not working

2 ビュー (過去 30 日間)
Mr.DDWW
Mr.DDWW 2022 年 4 月 28 日
回答済み: Star Strider 2022 年 4 月 28 日
I tried to run the code but it is not working. here is the code
here is the code
clc;clf;clear all;close all;
syms X(t) Y(t) Z(t) YF alpha beta gamma1 gamma2 T theta
% The given data
YF=0.0667;
alpha= 0.29;
beta= 0.68;
gamma1=450;
gamma2=11.25;
theta=0.10895;
Ode1 = diff(X) == -X/theta + (1+alpha)*gamma1*(1-X)*Y^2 + beta*gamma1*(1-X)*Z^2;
Ode2 = diff(Y) == (YF-Y)/theta+(1-alpha)*gamma1*(1-X)*Y^2-gamma2*Y;
Ode3 = diff(Z) == -Z/theta+beta*gamma1*(1-X)*Z^2+2*alpha*gamma1*(1-X)*Y^2-(gamma2*Z)/beta;
Odes = [Ode1;Ode2; Ode3];
[VF, Subs] = OdeToVectorField ([Ode1, Ode2,Ode3]);
M = matlabFunction (VF, 'Vars',{'T','Y'});
% The given condtions
[t,y]=ode45(M, [0 5],[0.0667 0 0]);
figure
plot(t,y(:,1:2))
gride on
title('X and Y')
legend (string(subs))
[t,y]=ode45(M, [100 120],[0.0667 0 0]);
figure
plot(t,y(:,1:2))
gride on
title('X and Y')
legend (string(subs))
[t,y]=ode45(M, [100 120],[0.0667 0 0]);
figure
plot(t,y(:,1),t,y(:,2))
gride on
title('X vs Y')
legend (string(subs))
  1 件のコメント
Torsten
Torsten 2022 年 4 月 28 日
編集済み: Torsten 2022 年 4 月 28 日

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

回答 (1 件)

Star Strider
Star Strider 2022 年 4 月 28 日
Problem:
[VF, Subs] = OdeToVectorField ([Ode1, Ode2,Ode3]);
Try this —
syms X(t) Y(t) Z(t) YF alpha beta gamma1 gamma2 T theta
% The given data
YF=0.0667;
alpha= 0.29;
beta= 0.68;
gamma1=450;
gamma2=11.25;
theta=0.10895;
Ode1 = diff(X) == -X/theta + (1+alpha)*gamma1*(1-X)*Y^2 + beta*gamma1*(1-X)*Z^2;
Ode2 = diff(Y) == (YF-Y)/theta+(1-alpha)*gamma1*(1-X)*Y^2-gamma2*Y;
Ode3 = diff(Z) == -Z/theta+beta*gamma1*(1-X)*Z^2+2*alpha*gamma1*(1-X)*Y^2-(gamma2*Z)/beta;
Odes = [Ode1;Ode2; Ode3];
[VF, Subs] = odeToVectorField ([Ode1, Ode2,Ode3]); % <— Corrected Misspelling
M = matlabFunction (VF, 'Vars',{'T','Y'});
% The given condtions
[t,y]=ode45(M, [0 5],[0.0667 0 0]);
figure
plot(t,y(:,1:2))
grid on
title('X and Y')
legend (string(Subs))
Warning: Ignoring extra legend entries.
[t,y]=ode45(M, [100 120],[0.0667 0 0]);
figure
plot(t,y(:,1:2))
grid on
title('X and Y')
legend (string(Subs))
Warning: Ignoring extra legend entries.
[t,y]=ode45(M, [100 120],[0.0667 0 0]);
figure
plot(t,y(:,1),t,y(:,2))
grid on
title('X vs Y')
legend (string(Subs))
Warning: Ignoring extra legend entries.
MATLAB is case-sensitive.
.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by