Error - Inputs must be floats 'ode45'
2 views (last 30 days)
Show older comments
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)
0 Comments
Accepted Answer
Alan Stevens
on 24 Nov 2020
Edited: Alan Stevens
on 24 Nov 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
0 Comments
More Answers (0)
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!