% minphase_part1.m
%
% A minimum phase low pass filter has specs passband
% 0 < f < 0.1, ripple +-0.1 dB, with width of transition
% band 0.025. The stopband has attenuation at least 40 dB.
%
freqs=[0 0.2 0.25 1];
mags=[1 1 0.00005 0.00005];
weights=[1 460];
Nprime=126
g=firpm(Nprime,freqs,mags,weights);
[f,G]=freqzamp(g,101,0.0,0.1);
figure
plot(f,G)
title(['pass band with Nprime = ',int2str(Nprime)])
ripple=(max(G)-min(G))/2
pause
[f,G]=freqzamp(g,501,0.0,0.5);
figure
plot(f,G)
title(['frequency response with Nprime = ',int2str(Nprime)])
Gmin=min(G)
pause
%
Nprime=128
g=firpm(Nprime,freqs,mags,weights);
[f,G]=freqzamp(g,101,0.0,0.1);
figure
plot(f,G)
title(['pass band with Nprime = ',int2str(Nprime)])
ripple=(max(G)-min(G))/2
pause
[f,G]=freqzamp(g,501,0.0,0.5);
figure
plot(f,G)
title(['frequency response with Nprime = ',int2str(Nprime)])
Gmin=min(G)
pause
%
N=(Nprime+2)/2;
g(N)=g(N)-Gmin;
figure
zplane(g);
z=roots(g);
zsave=[real(z) imag(z) abs(z)];
save gzeroes.txt zsave -ascii
