I am getting an error in ode45
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Ayush Ranjan
il 20 Apr 2023
Risposto: Cris LaPierre
il 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 Commenti
Risposta accettata
Cris LaPierre
il 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Ordinary Differential Equations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!