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)

 Respuesta aceptada

Alan Stevens
Alan Stevens el 24 de Nov. de 2020
Editada: Alan Stevens el 24 de Nov. de 2020
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

Más respuestas (0)

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Productos

Versión

R2020b

Etiquetas

Preguntada:

el 24 de Nov. de 2020

Editada:

el 24 de Nov. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by