%Niveen Bazaraa
%ECE 460 Control Systems
%Lab 3
%Tuesday 23 Sept 2003
%File name  Lab3B

clear all
home
t=[0:0.01:10]';
numGo=[0,-1,4];
denGo=[1,2,10];
numGr=[0,0,1];
denGr=[1,2,10];
systmGo = tf(numGo,denGo);        %defines system transfer function
systmGr = tf(numGr,denGr);
yi = impulse(systmGo,t);          %finds impulse response for time interval defined by t
ys = step(systmGr,t);             %finds step response for time interval defined by t
xt = yi + ys;
%[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(4,1,1)
plot(t,yi)
hold on
plot(t,ys)
hold on
plot(t,xt)
xlabel('The t axis')
ylabel('The y axis')
title('All three together')
grid on
subplot(4,1,2)
plot(t,yi)
xlabel('The t axis')
ylabel('The y axis')
title('The zero input response')
grid on
subplot(4,1,3)
plot(t,ys)
xlabel('The t axis')
ylabel('The y axis')
title('The zero state response')
grid on
subplot(4,1,4)
plot(t,xt)
xlabel('The t axis')
ylabel('The y axis')
title('The total response')
grid on