%lab3
%#7
clear
n=[0:255];
w=[0:pi/1024:pi];
wo=pi/128;
x=0;
for k=0:11
    x=x+cos(k*wo*(n-128));
end
Num=[9.88, -15.6, 6.2];
Den=[1, -.521,.121];
H=freqz(Num,Den,n);

y=filter(Num,Den,x);
FTy=fft(y,n);
GD=grpdelay(Num,Den,w);

subplot(3,1,1)
plot(n,y,n,x);
xlabel('n');
ylabel('Amplitude');
title('Lab3-#7- x(n) & y(n)');
grid on
axis([0,255,-10,20]);

subplot(3,1,2)
plot(n,abs(FTy),'r');
xlabel('n');
ylabel('Amplitude');
title('Magnitude Spectrum of y, Y(e^(jw))');
grid on
axis([0,255,0,15]);

subplot(3,1,3)
plot(w,GD);
xlabel('n');
ylabel('Samples');
title('Group Delay of Filter');
grid on
axis([0,pi,-7,1]);
zoom on


