Filter löschen
Filter löschen

I am getting an error in ode45

2 Ansichten (letzte 30 Tage)
Ayush Ranjan
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

Akzeptierte Antwort

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

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by