% limit.m - limit cycle example using oscillator + predator prey
% RMM, 9 Oct 04

% Simple nonlinear oscillator
%
% This is an example of a simple nonlinear oscillator that demonstrates
% a limit cycle

aminit;					% initialize MATALB

% First generate a time domain plot
tspan=[0 30]; x0=[0.1;0];
[t,x]=ode45('osc',tspan,x0);
figure(1); clf; subplot(221);
xy = plot(t, x(:,1), '-', t, x(:,2), '--');
set(xy, 'LineWidth', AM_data_linewidth);

amaxis([0 30 -2 2]);
xlabel('Time {\itt}');
ylabel('{\itx}_1, {\itx}_2', 'Rotation', 90);
lgh = legend('{\itx}_1', '{\itx}_2', 'Orientation', 'Horizontal'); 
legend(lgh, 'boxoff');
amprint('oscsim.eps');

% Now generate a phase portrait
figure(2); clf; subplot(221);
axis([-1.5 1.5 -1.5 1.5]);   set(gca,'DataAspectRatio', [1,1,1]);
set(gca, 'XLimMode', 'manual', 'YLimMode', 'manual');
amphaseplot('osc', 'timepts', [0.2, 0.8], NaN, ...
   [0 1.5; 0 -1.5; 1.5 0; -1.5 0; 1.5 -1.5; 1.5 1.5; -1.5 1.5; -1.5 -1.5], 5);
amaxis([-1.5 1.5 -1.5 1.5]);
hold on; amphaseplot('osc', 'logtime', [1, 0.2], NaN, ...
  [0 0.01; 0 -0.01; 0.01 0; -0.01 0], 8);
hold on; plot([0], [0], 'k.', 'MarkerSize', AM_data_markersize*3);
amaxis([-1.5 1.5 -1.5 1.5]);

xlabel('{\itx}_1'); ylabel('{\itx}_2', 'Rotation', 0);

amprint('oscpp.eps');

