フィルターのクリア

I am getting an error in ode45

2 ビュー (過去 30 日間)
Ayush Ranjan
Ayush Ranjan 2023 年 4 月 20 日
回答済み: Cris LaPierre 2023 年 4 月 20 日
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

採用された回答

Cris LaPierre
Cris LaPierre 2023 年 4 月 20 日
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 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by