%
% Example 8.4
%
% Modified February 6, 2004
num1=[1 2];
den1=[1 4 3];
num2=[1 7 10];
d1=[1 1];
d2=[1 3];
d3=[1 5.1];
d12=conv(d1,d2);
den2=conv(d12,d3);
[cnum1,cden1]=feedback(num1,den1,1,1,-1);
[cnum2,cden2]=feedback(num2,den2,1,1,-1);
t=0:0.1:2;
figure (1)
ya=step(cnum1,cden1,t);
yb=step(cnum2,cden2,t);
plot(t,ya,t,yb,'--'); title('Stable Dipole')
xlabel('Time [s]'); grid;
ylabel('Step reponses of the original and reduced-order systems')
axis([0 2 0 1])
%
% Unstable depole case
%
num1=[1 2];
den1=[1 4 3];
num2=[1 -3 -10];
d1=[1 1];
d2=[1 3];
d3=[1 -5.1];
d12=conv(d1,d2);
den2=conv(d12,d3);
[cnum1,cden1]=feedback(num1,den1,1,1,-1);
[cnum2,cden2]=feedback(num2,den2,1,1,-1);
t=0:0.1:2;
figure (2)
ya=step(cnum1,cden1,t);
yb=step(cnum2,cden2,t);
plot(t,ya,t,yb,'--'); title('Unstable Dipole')
xlabel('Time [s]'); grid;
ylabel('Step reponses of the original and reduced-order systems')
axis([0 2 0 1])