I have tried doing for 'n=5' and here is my code;
dx = @(t,x) [x(1); x(1)*(2-x(1)-x(2)); x(2); x(2)*(3-x(1)-x(2)-x(3)); x(3); x(3)*(3-x(2)-x(3)-x(4)); x(4); x(4)*(3-x(3)-x(4)-x(5)); x(5); x(5)*(2-x(4)-x(5))];tspan=[0 15];x0=[0 2 0 3 0 4 0 6 0 8];[t,x] = ode45(@(t,x) dx(t,x), tspan, x0);figure(1)plot(t, x)
Can someone please check if this code is correct, if not, how can I improve if and for any 'n'?. Thanks in advance.
Best Answer