フィルターのクリア

What am I doing wrong in my Ode?

1 回表示 (過去 30 日間)
Matthew Lozancich
Matthew Lozancich 2018 年 1 月 11 日
回答済み: David Goodmanson 2018 年 1 月 11 日
Can't seem to understand what I'm doing wrong.
function zombie
[t,x]=ode23(@zomb,[0,60],1000)
subplot(2,1,1)
plot(t,x(:,1))
subplot(2,1,2)
plot(t,x(:,2))
function dx=zomb(t,x)
mu=0.002;
delta=0.001;
beta=0.002;
gamma=0.0015;
dx=[mu*x(1) - beta*(x(1))*x(2) - delta*(x(1)); -gamma*x(1)*x(2) + beta*x(1)*x(2) - 150*delta*x(2)];
end
end

採用された回答

David Goodmanson
David Goodmanson 2018 年 1 月 11 日
Hi Matthew, you appear to lacking a second initial condition. With one initial condition of 1000, ode23 assumes that x has only one component and so 'zomb' bombs out on the x(2) variable. If you try, e.g.
[t,x]=ode23(@zomb,[0,60],[1000 5])
then it works.

その他の回答 (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