

%lab3
%4

clear
w=[0:pi/1024:pi];
wo=.25*pi;
N=conv([1, -exp(j*wo)],[1,-exp(-j*wo)]);
D=conv([1,-.8*exp(j*wo)],[1,-.8*exp(-j*wo)]);
H=freqz(N,D,w);
magH=abs(H);
phaseH=angle(H);


% this part is wrong.  I'd take the derivative of the magnitude spectrum
% and set it equal to zero.  the 2nd possible point would be the point in question.
magH(257)           % the 257th indecie is where magH(w)=0 i found this just by looking in the 
                    % output vector and it told me what indexie it was.

mag_zero=H(w==wo);
mag_zero

% we still need to find when the magnitude is .707 initial or 3 db down
% i think it is btw indexie 192 and 193, and 320 and 321

subplot(2,1,1)
plot(w,magH);
xlabel('\omega');
ylabel('Amplitude');
title('Lab3,#4-Magnitude spectrum');
grid on
axis([0,pi,0,1.4]);

subplot(2,1,2)
plot(w,phaseH);
xlabel('\omega');
ylabel('Radians');
title('Lab3,#4-Phase spectrum');
grid on
axis([0,pi,-2,2]);