% transient.m - transient response versus steady state
% RMM, 14 Sep 05
%
% This file generates an example of a steady state versus transient
% response.  The plot generated by this file is included in transient.fig,
% where it is annotated and used to generate the final figure, transient.pst

aminit;					% initialize MATALB

% Use the coupled spring mass system, with normalized steady state gain
sys = springmass();
sys = sys / freqresp(sys, 0);

% Create input vectors as a function of time
tvec = 0:0.1:80;
ss = ceil(length(tvec)/2):length(tvec);
u1 = 0.51 * sin(2* tvec);

[y1, x1] = lsim(sys, u1, tvec);

figure(1); clf; subplot(321);
xy = plot(tvec, u1); 
set(xy, 'LineWidth', AM_data_linewidth);

% Set up the axis labels
amaxis([0 80 -1 1]);
xlabel('Time {\itt} [sec]'); ylabel('Input {\itu}');

amprint('transient-input.eps');

figure(2); clf; subplot(322);
xy = plot(tvec, y1); 
set(xy, 'LineWidth', AM_data_linewidth);

% Add some labels of interesting features
arrow([18, -0.05], [4, -0.05], AM_small_arrowsize);
arrow([18, -0.05], [32, -0.05], AM_small_arrowsize);
amtext(18, -0.07, 'Transient', 'HorizontalAlignment', 'center');

arrow([55, -0.05], [76, -0.05], AM_small_arrowsize);
arrow([55, -0.05], [34, -0.05], AM_small_arrowsize); 
amtext(55, -0.07, 'Steady State', 'HorizontalAlignment', 'center');

line([33 33], [-0.075 -0.03], 'Color', 'k', 'LineWidth', AM_ref_linewidth);

% Set up the axis labels
amaxis([0 80 -0.1 0.1]);
xlabel('Time {\itt} [sec]'); ylabel('Output {\ity}');

amprint('transient-output.eps');
