Error in Error in odearguments (line 92) f0 = ode(t0,y0,args{:}); % ODE15I sets args{1} to yp0. Error in ode45 (line 104) odeargumen​ts(odeIsFu​ncHandle,o​deTreatAsM​File,

24 visualizaciones (últimos 30 días)
I've been trying to figure out what I'm doing wrong, but cant seem to find it, its a 2 part code:
clear all
function dy = juan(t,y)
global k1 k2 k3 kmin3 k4 k5 k6 k7
dy=zeros(6,1);
dy(1)=k1-k2.*y(1).*y(5);
dy(2)=k2.*y(1).*y(5)+kmin3.*y(3)-k3.*y(2);
dy(3)=k3.*y(2)+k5.*y(4)-k4.*y(3).*y(5)-k3.*y(3);
dy(4)=k4.*y(3).*y(5)-k5.*y(4)-k6.*y(4);
dy(5)=k7.*y(6)-k2.*y(1).*y(5)-k4.*y(3).*y(5);
dy(6)=-k7.*y(6)+k2.*y(1).*y(5)+k4.*y(3).*y(5);
end
That first part defines my ecuations, and the next one asignes values to k's, but always get errors even when its the same code as my professor
global k1 k2 k3 kmin3 k4 k5 k6 k7
k1= 0.25;
k2= 1;
k3= 1;
kmin3= 1;
k4= 1;
k5= 1;
k6= 1;
k7= 2.5;
[t,y]=ode45(@juan, [0 60], [0; 0; 0; 0; 0.5; 0.5])
Error in odearguments (line 92)
f0 = ode(t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 104)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
Error in COMANDOS (line 10)
[t,y]=ode45(@juan, [0 60], [0; 0; 0; 0; 0.5; 0.5])
  1 comentario
Torsten
Torsten el 23 de Feb. de 2024
Works for me.
global k1 k2 k3 kmin3 k4 k5 k6 k7
k1= 0.25;
k2= 1;
k3= 1;
kmin3= 1;
k4= 1;
k5= 1;
k6= 1;
k7= 2.5;
[t,y]=ode45(@juan, [0 60], [0; 0; 0; 0; 0.5; 0.5]);
plot(t,y)
grid on
function dy = juan(t,y)
global k1 k2 k3 kmin3 k4 k5 k6 k7
dy=zeros(6,1);
dy(1)=k1-k2.*y(1).*y(5);
dy(2)=k2.*y(1).*y(5)+kmin3.*y(3)-k3.*y(2);
dy(3)=k3.*y(2)+k5.*y(4)-k4.*y(3).*y(5)-k3.*y(3);
dy(4)=k4.*y(3).*y(5)-k5.*y(4)-k6.*y(4);
dy(5)=k7.*y(6)-k2.*y(1).*y(5)-k4.*y(3).*y(5);
dy(6)=-k7.*y(6)+k2.*y(1).*y(5)+k4.*y(3).*y(5);
end

Iniciar sesión para comentar.

Respuestas (1)

Steven Lord
Steven Lord el 23 de Feb. de 2024
Get rid of the line clear all at the start of your juan.m file.

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by