%Niveen Bazaraa
%ECE 460 Control Systems
%Lab 3
%Tuesday 23 Sept 2003
%Part A: a     
%G(s) = Y(s)/R(s) = 104 / (s^2 + 8s + 52)
%File name  Lab3A_program

clear all
home
time=input('How many seconds would you like to view the output y(t) ------>  ')
t=[0:0.01:time]';
fprintf('Enter the numerator array, for example  G(s) = 104 / (s^2 + 8s + 52). \n\n');
fprintf('you would enter [0,0,104] for the numerator coeffcients and [1,8,52] for denominator coefficents. \n\n');
num=input('Enter the numerator array ---->  ')
den=input('Enter the denominator array ---->  ')
%num=[0,0,104];
%den=[1,8,52];
systm = tf(num,den);            %defines system transfer function
yi = impulse(systm,t);          %finds impulse response for time interval defined by t
ys = step(systm,t);             %finds step response for time interval defined by t
[ypeak, ind] = max(ys)          %finds peak value of step respnse: note that
                                %ys(ind)=ypeak; and tpeak=t(ind);
[tp, os, ts] = tposts(t,ys)      %given time vector and the response vector, finds
                                %peak time overshoot and settling time 

subplot(2,1,1)
plot(t,yi)
xlabel('The t axis')
ylabel('The f axis')
title('The unit impulse response')
grid on
subplot(2,1,2)
plot(t,ys)
xlabel('The t axis')
ylabel('The f axis')
title('The unit step response')
grid on
diary off
