%lab3
%#6
clear
w=[0:pi/1024:pi];
N1=conv([1,-1],[1,-1]); %^2
N2=0.02426*conv(N1,N1); %^2*^2=^4
Num=conv(N2,[0.8,1]); %entire numerator
D1=[1,1.041,0.4019];
D2=[1,.5661,0.7657];
D3=conv(D1,D2);
Den=conv(D3,[1,0.8]);   %entire denominator
T=freqz(Num,Den,w);
magT=abs(T);
phaseT=angle(T);

grd=grpdelay(Num,Den,w);

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

subplot(2,2,2);
plot(w,20*log(magT));
xlabel('\omega');
ylabel('Amplitude in dB');
title('lab3-#6-Magnitude Spectrum in dB scale');
grid on
axis([0,pi,-600,20]);

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

subplot(2,2,4);
plot(w,grd);
xlabel('\omega');
ylabel('Samples');
title('lab3-#6-Group Delay of Filter');
grid on
axis([0,pi,0,10]);




