% Step response for a second order system
% BJ Furman
% 14SEP2013
% [d p] = min(abs(val-vector))

clear all
close all
zeta = [0, 0.2, 0.7, 1.0, 2, 3.0];
tfinal = 30; % end time if you define your own time vector
tdata = linspace(0, tfinal, 200); % time vector
for i = 1:length(zeta)
    [y t] = step(tf([0 0 1], [1 2*zeta(i) 1]),tdata);
    plot(t, y)
    axis([0 tfinal 0 2.1])
    % locate time point to place zeta
    [min_val ind] = min(abs(2.8 - t));
    text(t(ind),y(ind),['\zeta=',num2str(zeta(i))])
    hold on;
end
xlabel('Time')
ylabel('Response')
title('Second Order System Step Response')
grid