数字信号处理大作业汇总

y = fft(h, 10000); y = y(1:5000); y = 20 * log10(y);

n = linspace(0, pi, 5000); subplot(2, 2, 2) plot(n/pi, y)

%%%凯塞窗%%%%

bata = 0.5842 * (rs - 21)^0.4 + 0.07886 * (rs - 21); n = ceil((rs - 8)/2.285/b); wc = (wp + ws )/2/pi;

h = fir1(n, wc, 'low', kaiser(n+1, bata)); x = 0:length(h)-1;

subplot(2, 2, 3) stem(x, h, '.'); y = fft(h, 10000); y = y(1:5000); y = 20 * log10(y);

n = linspace(0, pi, 5000); subplot(2, 2, 4) plot(n/pi, y)

结果图分析:

题目四

利用Matlab工具箱函数fir1,设计线性相位FIR数字高通滤波器,要求通带截止频率为0.6πrad,阻带截止频率为0.45πrad。通带最大衰减为0.2dB,阻带最小衰减为45dB。分别用汉宁窗、汉明窗、布莱克曼窗和凯塞窗进行设计,显示所设计滤波器的单位脉冲响应h(n)的数据,并画出幅频响应特性曲线和相频响应特性曲线,请对每种窗函数的设计结果进行比较。 问题分析:

(1)根据技术要求,提出线性相位FIR数字高通滤波器的指标。

通带截止频率wp=0.6πrad,阻带截止频率为ws=0.45πrad。通带最大衰减为rp=0.2dB,阻带最小衰减为rs=45dB

(2)计算过渡带宽度:wp = 0.6*pi; ws = 0.45*pi; b = wp - ws; 计算h(n)长度:n0 =ceil(t * pi / b) 确保n是奇数:n = n0 + mod(n0+1, 2);

计算理想高通滤波器通带截止频率:wc = (wp + ws )/2/pi; (3)使用fir1函数产生线性相位FIR数字高通滤波器

h = fir1(n-1, wc, 'high', hanning(n));t=6.2; h = fir1(n-1, wc, 'high', hamming(n));t=6.6; h = fir1(n-1, wc, 'high', blackman(n));t=11; h = fir1(n, wc, 'high', kaiser(n+1, bata)); 原始MATLAB程序:

%%%%%%%%%%%%%%%汉宁窗%%%%%%%%%%%%%%%%%%%

wp = 0.6*pi; ws = 0.45*pi; b = wp - ws;rs = 45; n0 = ceil(6.2 * pi / b) n = n0 + mod(n0+1, 2);

wc = (wp + ws )/2/pi;

h = fir1(n-1, wc, 'high', hanning(n)); x = 0:length(h)-1; figure(1)

subplot(2, 2, 1),stem(x, h, '.'); y = fft(h, 10000); y = y(1:5000);

y = 20 * log10(y);

n = linspace(0, pi, 5000);

subplot(2, 2, 2),plot(n/pi, y);

%%%%%%%%%%%%%%%汉明窗%%%%%%%%%%%%%%%%%%%% n0 = ceil(6.6 * pi / b) n = n0 + mod(n0+1, 2); wc = (wp + ws )/2/pi;

h = fir1(n-1, wc, 'high', hamming(n)); x = 0:length(h)-1; subplot(2, 2, 3) stem(x, h, '.'); y = fft(h, 10000); y = y(1:5000);

y = 20 * log10(y);

n = linspace(0, pi, 5000); subplot(2, 2, 4) plot(n/pi, y)

%%%%%%%%%%%%%%%%布莱克曼窗%%%%%%%%%%%%%%%%%%% n0 = ceil(11 * pi / b) n = n0 + mod(n0+1, 2); wc = (wp + ws )/2/pi;

h = fir1(n-1, wc, 'high', blackman(n)); x = 0:length(h)-1; figure(2)

subplot(2, 2, 1) stem(x, h, '.'); y = fft(h, 10000); y = y(1:5000);

y = 20 * log10(y);

n = linspace(0, pi, 5000); subplot(2, 2, 2)

plot(n/pi, y),,grid on

xlabel('频率(KHz)');ylabel('幅度(dB)'); %%%%%%%%%%%%%%%凯塞窗%%%%%%%%%%%%%%%%%%%%

bata = 0.5842 * (rs - 21)^0.4 + 0.07886 * (rs - 21); n = ceil((rs - 8)/2.285/b)+1; wc = (wp + ws )/2/pi;

h = fir1(n, wc, 'high', kaiser(n+1, bata)); x = 0:length(h)-1;

subplot(2, 2, 3) stem(x, h, '.'); y = fft(h, 10000); y = y(1:5000);

y = 20 * log10(y);

n = linspace(0, pi, 5000); subplot(2, 2, 4) plot(n/pi, y)

结果图分析:

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4