%lab3
%#5
clear
w=[0:pi/1024:2*pi];
N1=[.287,-.447];
D1=[1,-1.297,.695];
N2=[-2.142, 1.145];
D2=[1,-1.069,.37];
N3=[1.856,-0.63];
D3=[1,-0.997,0.257];
a=conv(conv(D2,D3),N1);
b=conv(conv(D1,D3),N2);
c=conv(conv(D1,D2),N3);
Num=a+b+c;
Den=conv(conv(D1,D2),D3);
T=freqz(Num,Den,w);
magT=abs(T);
phaseT=angle(T);

grd=grpdelay(Num,Den,w);

subplot(3,1,1)
plot(w,magT);
xlabel('\omega');
ylabel('Amplitude');
title('Lab3-#5-Magnitude Spectrum');
grid on
axis([0,2*pi,0,1]);

subplot(3,1,2)
plot(w,phaseT);
xlabel('\omega');
ylabel('Radians');
title('Lab3-#5-Phase Spectrum');
grid on
axis([0,2*pi,-3,3]);

subplot(3,1,3)
plot(w,grd);
xlabel('\omega');
ylabel('Samples');
title('Lab3-#5-Group Delay of Filter');
grid on
axis([0,2*pi,-2,10]);



