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,

조회 수: 30 (최근 30일)
Juan
Juan 2024년 2월 23일
댓글: Torsten 2024년 2월 23일
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
Torsten
Torsten 2024년 2월 23일
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

댓글을 달려면 로그인하십시오.

답변 (1개)

Steven Lord
Steven Lord 2024년 2월 23일
Get rid of the line clear all at the start of your juan.m file.

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by