I am getting an error in ode45
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ayush Ranjan
am 20 Apr. 2023
Beantwortet: Cris LaPierre
am 20 Apr. 2023
function main
tspan = 0:30;
yo=[0.01 0.05 0.539];
yo=yo(:);
dydt=zeros(3,1);
[t,y]=ode45(@newwaykumar2004,tspan,yo);
function dydt=newwaykumar2004(t,y)
kp=3;
kpm = 3;
kmp = 25;
klm = 15;
kl = 1;
theta=1;
w=0.5;
function qz=f(m)
qz=1+tanh((m-theta)/w);
end
dydt(1)=kp*y(1)*(1-y(1))-kpm*y(1)*y(2);
dydt(2)=(kmp*y(1)+y(3))*y(2)*(1-y(2))-y(2);
dydt(3)=klm*f(y(2))-kl*y(3);
end
end
0 Kommentare
Akzeptierte Antwort
Cris LaPierre
am 20 Apr. 2023
It's helpful if you also share the error you are getting.
In this case, the error is stating that your odefun must return a column vector. It is currently returning a row vector. You can fix this by adding a column index of 1 in your assignments to dydt.
dydt(1,1)=kp*y(1)*(1-y(1))-kpm*y(1)*y(2);
dydt(2,1)=(kmp*y(1)+y(3))*y(2)*(1-y(2))-y(2);
dydt(3,1)=klm*f(y(2))-kl*y(3);
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!