Error in Error in odearguments (line 92) f0 = ode(t0,y0,args{:}); % ODE15I sets args{1} to yp0. Error in ode45 (line 104) odearguments(odeIsFuncHandle,odeTreatAsMFile,
24 ビュー (過去 30 日間)
古いコメントを表示
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
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
2024 年 2 月 23 日
Get rid of the line clear all at the start of your juan.m file.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!