Effacer les filtres
Effacer les filtres

I am getting an error in ode45

2 vues (au cours des 30 derniers jours)
Ayush Ranjan
Ayush Ranjan le 20 Avr 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

Réponse acceptée

Cris LaPierre
Cris LaPierre le 20 Avr 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);

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by