Not enough input arguments using ode45
Show older comments
I'm trying to simulate a non linear prey-predator system using ode45, but I'm pretty new to Matlab functions and keep getting errors.
close; clear;
timerange = [0 20];
IC=[1; 1; 1; 1];
r = [1 0.72 1.53 1.27];
a = [1 1.09 1.52 0;
0 1 0.44 1.36;
2.33 0 1 0.47;
1.21 0.51 0.35 1];
IC=[1 1 1 1];
fun = @(t, x)predapredatore(x, r, a);
[t, x]=ode45(predapredatore,timerange,IC);
plot(t, x)
function dx=predapredatore(x, r, a)
dx= [r(1)*x(1)*(1 - a(1,1)*x(1) - a(1,2)*x(2) - a(1,3)*x(3) - a(1,4)*x(4));...
r(2)*x(2)*(1 - a(2,1)*x(1) - a(2,2)*x(2) - a(2,3)*x(3) - a(2,4)*x(4));...
r(3)*x(3)*(1 - a(3,1)*x(1) - a(3,2)*x(2) - a(3,3)*x(3) - a(3,4)*x(4));...
r(4)*x(4)*(1 - a(4,1)*x(1) - a(4,2)*x(2) - a(4,3)*x(3) - a(4,4)*x(4));];
end
The errors I get are:
Not enough input arguments.
Error in preypredator>predapredatore (line 28)
dx= [r(1)*x(1)*(1 - a(1,1)*x(1) - a(1,2)*x(2) - a(1,3)*x(3) - a(1,4)*x(4));...
Error in preypredator (line 13)
[t, x]=ode45(predapredatore,timerange,IC);
Where am I missing input arguments? And what type of errors are in line 28 and 13?
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations 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!