内容发布更新时间 : 2025/1/5 17:55:32星期一 下面是文章的全部内容请认真阅读。
DSP题库详解
1已知3阶椭圆IIR数字低通滤波器的性能指标为:通带截止频率0.4π,通带波纹为0.6dB,最小阻带衰减为32dB。设计一个6阶全通滤波器对其通带的群延时进行均衡。绘制低通滤波器和级联滤波器的群延时。
%Progranm 1
% Group-delay equalization of an IIR filter. %
[n,d] = ellip(3,0.6,32,0.4); [GdH,w] = grpdelay(n,d,512); plot(w/pi,GdH); grid
xlabel('\\omega/\\pi'); ylabel('Group delay, samples'); title('Original Filter');
F = 0:0.001:0.4;
g = grpdelay(n,d,F,2); % Equalize the passband Gd = max(g)-g;
% Design the allpass delay equalizer
[num,den,tau] = iirgrpdelay(6, F, [0 0.4], Gd); %设计六阶的全通滤波器
[b,a]=iirgrpdelay(6,F,[0 0.4],Gd); He1=dfilt.df2(b,a); He=dfilt.df2(n,d);
He_all=dfilt.cascade(He,He1);
grpdelay(He_all) ?ILT:Digital Filter Implementation. [GdA,w] = grpdelay(num,den,512); figure(2);
plot(w/pi,GdH+GdA); grid
xlabel('\\omega/\\pi');ylabel('Group delay, samples'); title('Group Delay Equalized Filter');
2设计巴特沃兹模拟低通滤波器,其滤波器的阶数和3-dB截止频率由键盘输入,程序能根据输入的参数,绘制滤波器的增益响应。
% Program 2
% Program to Design Butterworth Analog Lowpass Filter %
% Type in the filter order and passband edge frequency设计边缘频率 N = input('Type in filter order = ');
Wn = input('3-dB cutoff angular frequency = '); % Determine the transfer function [num,den] = butter(N,Wn,'s'); %计算滤波器的分子和分母 % Compute and plot the frequency response
[h,w]=freqz(num,den);
plot (w/pi,20*log10(abs(h)));
xlabel('\\omega/\\pi'); ylabel('Magnitude, dB'); title('The magnitude respponse of the system') axis([0 3 -80 5])
3%%%%%%%%%%
% To use the residue %
num=[1,-0.2,0.5,0,0]; den=[1,3.2,1.5,-0.8,1.4]; [r,p,k]=residuez(num,den)
4% Program 4
% Cheby1 analog highpass filter design %
Wp=0.75;Ws=0.35;Rs=43;Rp=0.5; [N,Wn]=cheb1ord(Wp,Ws,Rp,Rs,'s');
% Determine the coefficients of the transfer function [num,den]=cheby1(N,Rp,Wn,'high','s');
% Compute and plot the frequency response omega=[0:1:30*pi]; %w=0:0.01:pi; h=freqs(num,den,omega); %plot(w/pi,20*log10(abs(h))) plot(omega/(2*pi),20*log10(abs(h)));
xlabel('\\omega/\\pi');ylabel('Magnitude,dB'); title('IIR Chebyshev1 Highpass Filter/digital') 5.
% Program to 绘制30点序列的实部与虚部 % n=0:29;
x=0.2*exp((0.4+0.5*j).*n); subplot(1,2,1) stem(n,real(x))
title('The real part ');
xlabel('n');ylabel('magnitude') subplot(1,2,2) stem(n,imag(x))
title('The imagine part')
xlabel('n');ylabel('magnitude') 6.
% Program to Design Type 1 Chebyshev analog Lowpass Filter %
% Read in the filter order, passband edge frequency % and passband ripple in dB N = input('Order = ');
Wc = input('type in the 3 dB cutoff frequency=');
Rp = input(' Type in the peak ripple value in passband: '); % Determine the coefficients of the transfer function [num,den] = cheby1(N,Rp,Wc,'s');
% Compute and plot the frequency response [h,w]=freqs(num,den); plot (w/pi,20*log10(abs(h)));
xlabel('Frequency, Hz'); ylabel('magnitude, dB'); title('IIR Chebyshev1 Lowpass Filter/analog') grid on 7.
% Determination of the Factored Form % of a Rational z-Transform
%熟悉命令[num,den]=residuez(r,p,k);[r,p,k]=residuez(num,den) clear all
r = [1 0.6 1.8]; p =[-3.2 2.4 2.4]; k =0.2;
[num, den] = residuez(r,p,k);
disp('Numerator polynomial coefficients'); disp(num) disp('Denominator polynomial coefficients'); disp(den)
8, 设计IIR数字带通滤波器
% Program to Design iir digital bandpass Filter clear all
Wp = [0.4 0.6]; %Wp and Ws 都是向量组,带通的性质 Ws = [0.3 0.7]; Rp = 0.6; Rs = 35;
[N,Wn] = buttord(Wp, Ws, Rp, Rs); [b,a] = butter(N,Wn); %巴特卧兹滤波器的分子和分母 [h,w] = freqz(b,a,256); %求出在频域的画图点,256,即要花的点数 gain = 20*log10(abs(h)); plot (w/pi,gain);grid on
xlabel('\\omega/\\pi'); ylabel('magnitude, dB'); title('IIR Butterworth Bandpass Filter');
9%draw the requested sequence clear n=0:23; x=2*0.9.^n;