%Demo done during Session 18 demonstrating
%efficacy of FIR Lowpass Filter design via
%Remez Exchange Algorithm (Parks-McClellan)
clf
set(0,'defaultaxesfontsize',20);
Wp=2*pi*(4/24); Ws=2*pi*(6/24);
F=[Wp/pi Ws/pi];
DEV=[0.1 0.01];
A=[1 0];
[M,Fo,Ao,W] = remezord(F,A,DEV);
W=[1 10];
hlp=remez(M,Fo,Ao,W);
N=512;
hlpfft=fftshift(fft(hlp,N));
subplot(211)
hlpmag=20*log10(abs(hlpfft));
hlpmag=hlpmag-max(hlpmag);
hlpang=angle(hlpfft);
freqomega=linspace(-pi,pi,N);
plot(freqomega,hlpmag,'Linewidth',4);
miny=max(-100,min(hlpmag));
axis([-pi pi miny 0]);
title('Lowpass Filter Magnitude Response'),...
xlabel('Omega'), ylabel('Magnitude'), grid
hold on
for m=1:length(F),
plot([pi*F(m) pi*F(m)],[miny 0],'r--','Linewidth',4);
end
hold off
subplot(212)
plot(freqomega,hlpang,'Linewidth',4);
axis([-pi pi -pi pi]);
title('Phase Response'),...
xlabel('Omega'), ylabel('Phase'), grid
