%Tan Nguyen, Trang Pham, Nhan Phan
%ECE 460 Lab
%WINTER 2003
%Lab #2
%Part A: Unit Impulse and Step response
%Given the system transfer function G(s)=Y(s)/R(s)=104/s^2+8s+52
%a) Using Matlab function impulse and step determine unit impulse 
%response yt and unit step response ys.
%Use t=[0:.01:3]'
%From the step response determine the peak overshoot, peak time, 
%and settling time.
t=[0:0.01:3]'; %watch the response for 3 seconds
num=104;
den=[1 8 52];
sys=tf(num,den) %transfer function
yi=impulse(sys,t);
ys=step(sys,t)
figure(1);
subplot(3,1,1)
plot(t,yi);
title('The plot of impulse response');
grid on
subplot(3,1,2)
plot(t,ys)
title('The plot of step response ')
grid on
[tp, os, ts] = tposts(t, ys)


%d) Using matlab compute y(t) over the time interval defined in step (a) and graphically compare it with ys
s=sym('s');
y=(1/s)*((104)/(s^2+8*s+52));
yt=ilaplace(y)
yt=2-13/18*(-144)^(1/2)*(1/(-4+1/2*(-144)^(1/2))*exp((-4+1/2*(-144)^(1/2))*t)-1/(-4-1/2*(-144)^(1/2))*exp((-4-1/2*(-144)^(1/2))*t))
 
 subplot(3,1,3)
 plot(t,yt)
  title('Step response of y(t)');
 grid on
 
 Transfer function:
     104
--------------
s^2 + 8 s + 52
 
 tp =

    0.5200


os =

    0.1231


ts =

    0.8200
