On 3 Apr 2009, at 14:55, Johannes Wolfgang Woger wrote:
Hi,
I am an newby.
How can I obtain a plot of the phase portrait
of Lotka-Volterra:
octave:92> function xdot = f(x,t)
a = 4;
b = 4;
c = 4;
d = 8;
E = 1;
K = 1;
xdot = zeros(2,1);
xdot(1) = x(1)*(a-b*x(2)-E*x(1));
xdot(2) = x(2)*(d*x(1)-c-K*x(2));
endfunction
octave:93>
octave:93> t = linspace(0,50,100);
octave:94> x = lsode("f", [2,1],t);
octave:95> plot(t,x);
plot(x(:,1), x(:,2));
xlabel("x_1");
ylabel("x_2");
but I would suggest using a few more time steps if you want a nice
looking spiral...