% PLot of the DTFT of the moving average system
% Encoded in MATLAB by Morteza Rajabzadeh

clear all
close all
NN = 2; % number of cycles to be plotted
w = -NN*pi:.1:NN*pi;
H_real = sin(2.5*w)./sin(w/2)/5;
H = exp(-2*1i*w).*H_real;

subplot(2,1,1)
plot(w,H_real,'g')
hold on 
plot(w,abs(H),':')

ind = -NN*pi:pi:NN*pi;ind_val = zeros(size(ind));
plot(ind,ind_val,'ro')
legend('The absolute value','the value of real part','the place of \pi coefficients')
xlabel('\omega');title('the absolute value')
subplot(2,1,2)
plot(w,angle(H))
hold on 
plot(ind,ind_val,'ro')
xlabel('\omega');title('the phase')