% Short demo script to show Parks McClellan algorithm
% This version shows effect of N

% Parameters:
% 	N - size of FIR filter *** MUST BE ODD FOR PLOTS TO WORK OUT! ***

% Last revised 11/8/99 - rms


for N = 13:2:27,

F = [0 .4 .5 1];
A = [1 1 0 0];

b = remez(N-1,F,A);

%Compute the DTFT
n = -(N-1)/2 : (N-1)/2;
w = 0:pi/100:pi;
[H] = dtft(b,n,w);


plot(w/pi,real(H),'r')
hold on
plot(F(1:2),A(1:2))
plot(F(3:4),A(3:4))
hold off
xlabel('\omega/\pi','fontsize',14)
ylabel('|X(e^j^\omega)|','fontsize',14)
ylabel('Magnitude in dB','fontsize',14)
%iw = num2str(wp);
iN = num2str(N);
title(['Equiripple Filter, N = ',iN],'fontsize',14)

pause
end



% Show log plot, too


% Show magnitude in dB, too
for N = 13:2:27,

F = [0 .4 .5 1];
A = [1 1 0 0];

b = remez(N-1,F,A);

n = -(N-1)/2 : (N-1)/2;
w = 0:pi/100:pi;
[H] = dtft(b,n,w);

plot(w/pi,20*log10(abs(H)),'r')
hold on
plot(F(1:2),20*log10(A(1:2)))
hold off
xlabel('\omega/\pi','fontsize',14)
ylabel('|X(e^j^\omega)|','fontsize',14)
ylabel('Magnitude in dB','fontsize',14)
axis([0 1 -60 10])
iN = num2str(N);
title(['Equiripple Filter, N = ',iN],'fontsize',14)
pause
end


