clear all; close all;
rhoM = [0.5 0.99]; N = 8;
%% Q2_a
for k = 1:length(rhoM);
   omega = 0:2*pi/80:2*pi;  
   rho = rhoM(k);
   z1 = rho*exp(1j*2*pi/3); z2 = 1/rho; N = 8;
   Eh = 1 + (abs(z1+z2))^2 + (abs(z1)*abs(z2))^2;
   z = exp(j*omega);
   H = (1-z1*z.^(-1)).*(1-z2*z.^(-1)); 
   H = H/sqrt(Eh); %Normalize H
   subplot(1,2,k);
   plot(omega,abs(H),'k-');
   hold on; ylabel('H(\omega)'); xlabel('\omega'); grid on; 
   title(strcat('\rho = ',num2str(rho)));
   xlim([0,2*pi])
   end
%% Q2_b
for k = 1:length(rhoM);
   omega = 2*pi/N*(0:N-1);
   rho = rhoM(k);
   z1 = rho*exp(1j*2*pi/3); z2 = 1/rho; N = 8;
   Eh = 1 + (abs(z1+z2))^2 + (abs(z1)*abs(z2))^2;
   z = exp(j*omega);
   H = (1-z1*z.^(-1)).*(1-z2*z.^(-1));
   H = H/sqrt(Eh); %Normalize H
   subplot(1,2,k);
   plot(omega,abs(H),'b*');
   end