Error - Inputs must be floats 'ode45'

I am trying to solve two odes using ode45 and getting the same error everytime and i cant seem to work out why..
any help would be appreciated, thanks!
syms u v
a = 0.2;
c = 1;
b = (2*c/(1-a));
s(1) = u;
s(2) = v;
inital(1)=1;
inital(2)=1;
l = @(t,y) [s(1)*(1-s(1))*(a+s(1))-s(1)*s(2); b*s(1)*s(2)-s(2)];
[t,x] = ode45(l, [0, 200], inital)

 採用された回答

Alan Stevens
Alan Stevens 2020 年 11 月 24 日
編集済み: Alan Stevens 2020 年 11 月 24 日

1 投票

Like so (Note: no need for syms):
a = 0.2;
c = 1;
b = (2*c/(1-a));
inital(1)=1;
inital(2)=1;
l = @(t,s) [s(1)*(1-s(1))*(a+s(1))-s(1)*s(2); b*s(1)*s(2)-s(2)]; % Note: l = @(t,s) ...etc
[t,s] = ode45(l, [0, 200], inital); % Note [t, s] = ...etc.
u = s(:,1);
v = s(:,2);
plot(t,u,t,v),grid

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

製品

リリース

R2020b

タグ

質問済み:

2020 年 11 月 24 日

編集済み:

2020 年 11 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by