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)

 采纳的回答

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 Exchange 中查找有关 Programming 的更多信息

产品

版本

R2020b

标签

Community Treasure Hunt

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

Start Hunting!

Translated by