% We'll start with some random data: title('Messy Random Data Plot'); plot(rand(100,1),"-*;;") clg pause(1) % here's the solution of a system of differential equations: % gradient: function xdot = f (x, t) r = 0.25; k = 1.4; a = 1.5; b = 0.16; c = 0.9; d = 0.8; xdot(1) = r*x(1)*(1 -x(1)/k) - a*x(1)*x(2)/(1 + b*x(1)); xdot(2) = c*a*x(1)*x(2)/(1 + b*x(1)) - d*x(2); endfunction % initial value: x0 = [1; 2] % set of times at which to solve: t = linspace (0, 50, 200)'; % and the solution, using lsode: x = lsode ("f", x0, t); % time for a plot! title('ODE solution'); plot (t, x) clg pause(1) % note how it handles a vector, plotting both coordinates against time. title('ODE solution: second coordinate'); plot (t, x(:,2)) clg title('sines and cosines'); t = 0:0.1:6.3; plot (t, cos(t), "-;cos(t);", t, sin(t), "+3;sin(t);");