% secord_stepresp.m - Step response for a second-order system
% RMM, 2008

aminit;					% initialize MATALB

%Step responses for system with two poles
t=0:0.1:15;
w0=1;

% Generate the responses and plot the eigenvalues
figure(1); clf; subplot(221);

% Set up the axes
axis on; ampolezero(tf([1], [1]), [-3 1 -2 2]);
set(gca, 'DataAspectRatio', [1 1 1]);

% Plot the eigenvalues and compute step responses
z=0.0;
  G=tf([w0^2],[1 2*z*w0 w0^2]);
  hold on; eigplot(pole(G), 'bx', 'MarkerSize', AM_pzmap_markersize);
  plot([0.125 0.5], [1.05 1.3], 'k-', 'LineWidth', AM_thin_linewidth);
  amtext(0.6, 1.4, 'z = 0'); 
  y0=step(G,t);
z=0.4;
  G=tf([w0^2],[1 2*z*w0 w0^2]);
  eigplot(pole(G), 'bx', 'MarkerSize', AM_pzmap_markersize);
  plot([-0.525 -0.9], [1 1.35], 'k-', 'LineWidth', AM_thin_linewidth);
  amtext(-1.9, 1.5, 'z = 0.4'); 
  y05=step(G,t);
z=0.7;
  G=tf([w0^2],[1 2*z*w0 w0^2]);
  eigplot(pole(G), 'bx', 'MarkerSize', AM_pzmap_markersize);
  plot([-0.825 -1.3], [0.75 1.0], 'k-', 'LineWidth', AM_thin_linewidth);
  amtext(-2.35, 1.05, 'z = 0.7'); 
  y07=step(G,t);
z=1.0;
  G=tf([w0^2],[1 2*z*w0 w0^2]);
  eigplot(pole(G) + [0.015; -0.015], 'bx', 'MarkerSize', AM_pzmap_markersize);
  plot([-1.1 -1.575], [0.1 0.35], 'k-', 'LineWidth', AM_thin_linewidth);
  amtext(-2.35, 0.4, 'z = 1'); 
  y10=step(G,t);
z=1.2;
  G=tf([w0^2],[1 2*z*w0 w0^2]);
  eigplot(pole(G), 'bx', 'MarkerSize', AM_pzmap_markersize);
  plot([-0.55 -1.5], [-0.1 -0.6], 'k-', 'LineWidth', AM_thin_linewidth);
  plot([-1.85 -1.5], [-0.1 -0.6], 'k-', 'LineWidth', AM_thin_linewidth);
  amtext(-1.8, -0.75, 'z = 2'); 
  y20=step(G,t);

amprint('secord-stepeigs.eps');

% Plot the step responses
figure(2); clf; subplot(211)
pl = plot(t, y0, '-', t, y05, '-', t, y07, 'r-', t, y10, 'b-', t, y20, '-');
set(pl, 'LineWidth', AM_ref_linewidth);
hold on; plot(t,ones(length(t)), 'k', 'LineWidth', AM_thin_linewidth);

amaxis; daspect(daspect * diag([1 2 1]));
xlabel('x'); ylabel('y', 'Rotation', 0)
arcarrow([1.3 1.2], [3.5 0.6], -8); amtext(3.7, 0.6, 'zeta');

amprint('secord-stepresp.eps');

