%TimeResponse_2.m
%Effect of pole position
%Second order systems
%Impulse and Step response
%Introduction to:
%commands for zero/pole map
%- pzmap
%commands for system simulation
%- impulse
%- step


clc
echo on

wn=input('\nEnter natural frequency: ');
eta=input('\nEnter damping ratio: ');

%T(s)=wn^2/(s^2+2*eta*wn*s+wn^2)
fprintf('\nT(s)=wn^2/(s^2+2*eta*wn*s+wn^2)\n')
num1=wn^2;
den1=[1 2*eta*wn wn^2]
z1=roots(num1)
p1=roots(den1)
sys1=tf(num1,den1)
figure(1)
pzmap(sys1)
fprintf('\nPress a key to continue ... \n')
pause
figure(2)
[y,t]=impulse(sys1,20);
fprintf('\nPress a key to continue ... \n')
plot(t,y)
pause
figure(3)
[y,t]=step(sys1,20);
plot(t,y)

echo off