Effacer les filtres
Effacer les filtres

ODE code is not working

2 vues (au cours des 30 derniers jours)
Mr.DDWW
Mr.DDWW le 28 Avr 2022
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 commentaire
Torsten
Torsten le 28 Avr 2022
Modifié(e) : Torsten le 28 Avr 2022

Connectez-vous pour commenter.

Réponses (1)

Star Strider
Star Strider le 28 Avr 2022
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.
.

Catégories

En savoir plus sur Numerical Integration and Differential Equations dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by