% nlsmplots.m - generate time and phase plots for nonlinear spring mass
% RMM, 25 Aug 05

aminit;					% initialize MATALB

% Simulation of the nonlinear spring mass system
figure(1);
[t, y] = ode45('nlspringmass', [0 16], [2 0]);

figure(1); clf; subplot(221);
h = plot(t, y(:,1), '-', t, y(:,2), '--'); 
set(h, 'LineWidth', AM_data_linewidth);

amaxis([0 16 -2 2]);
xlabel('time (sec)'); ylabel('pos (m), vel (m/sec)','Rotation', 90);
legh = legend(' position', ' velocity'); legend(legh, 'boxoff');
amprint('nlsmtime.eps');

% Generate a phase plot for the damped oscillator
figure(2); clf; subplot(221); 
amphaseplot('nlspringmass', ...
  [-1 1 8], [-1 1 8], 0.2, ...
  [[-1 0.5; -1 0.75; 0.2 1; 0.5 1; 0.78 1; 1 -0.7; 0 -1; -0.34 -1; -0.6 -1]]);
a=gca;
  set(a,'XLim', [-1, 1]); set(a,'YLim', [-1, 1]);
  set(a,'DataAspectRatio',[1,1,1]);
amaxis;
xlabel('pos (m)'); ylabel('vel (m/sec)','Rotation', 90);
amprint('nlsmphase.eps');
