% Program 9_1
% Elliptic IIR Lowpass Filter Design
%
Wp = input('Normalized passband edge = ');
Ws = input('Normalized stopband edge = ');
Rp = input('Passband ripple in dB = ');
Rs = input('Minimum stopband attenuation in dB = ');
[N,Wn] = ellipord(Wp,Ws,Rp,Rs)
[b,a] = ellip(N,Rp,Rs,Wn);
[h,omega] = freqz(b,a,256);
plot (omega/pi,20*log10(abs(h)));grid;
xlabel('\omega/\pi'); ylabel('Gain, dB');
title('IIR Elliptic Lowpass Filter');
% Program 9_2
% Type 1 Chebyshev IIR Highpass Filter Design
%
Wp = input('Normalized passband edge = ');
Ws = input('Normalized stopband edge = ');
Rp = input('Passband ripple in dB = ');
Rs = input('Minimum stopband attenuation in dB = ');
[N,Wn] = cheb1ord(Wp,Ws,Rp,Rs);
[b,a] = cheby1(N,Rp,Wn,'high');
[h,omega] = freqz(b,a,256);
plot (omega/pi,20*log10(abs(h)));grid;
xlabel('\omega/\pi'); ylabel('Gain, dB');
title('Type I Chebyshev Highpass Filter');
% Program 9_3
% Design of IIR Butterworth Bandpass Filter
%
Wp = input('Passband edge frequencies = ');
Ws = input('Stopband edge frequencies = ');
Rp = input('Passband ripple in dB = ');
Rs = input('Minimum stopband attenuation = ');
[N,Wn] = buttord(Wp, Ws, Rp, Rs);
[b,a] = butter(N,Wn);
[h,omega] = freqz(b,a,256);
gain = 20*log10(abs(h));
plot (omega/pi,gain);grid;
xlabel('\omega/\pi'); ylabel('Gain, dB');
title('IIR Butterworth Bandpass Filter');
% Program 9_4
% Group-delay equalization of an IIR filter.
%
[n,d] = ellip(4,1,35,0.3);
[GdH,w] = grpdelay(n,d,512);
plot(w/pi,GdH); grid
xlabel('\omega/\pi'); ylabel('Group delay, samples');
title('Original Filter');
pause
F = 0:0.001:0.3;
g = grpdelay(n,d,F,2); % Equalize the passband
Gd = max(g)-g;
% Design the allpass delay equalizer
[num,den,tau] = iirgrpdelay(8, F, [0 0.3], Gd);
[GdA,w] = grpdelay(num,den,512);
plot(w/pi,GdH+GdA); grid
xlabel('\omega/\pi');ylabel('Group delay, samples');
title('Group Delay Equalized Filter');
No comments:
Post a Comment