代码:

子函数ampl_res

function [Hr,w,P,L] = ampl_res(h);
%
% function [Hr,w,P,L] = Ampl_res(h)
% Computes Amplitude response Hr(w) and its polynomial P of order L,
% given a linear-phase FIR filter impulse response h.
% The type of filter is determined automatically by the suroutine.
%
% Hr = Amplitude Response
% w = Frequence between [0 pi] over which Hr is computed
% P = Polynomial coefficients
% L = Order of P
% h = Linear Phase filter impulse response
%
M = length(h);
if rem(M,2)==1
if all(h(1:(M-1)/2)==h(M:-1:(M+3)/2)) [Hr,w,P,L] = Hr_Type1(h);
elseif all(h(1:(M-1)/2)==-h(M:-1:(M+3)/2)) & h((M+1)/2)==0, [Hr,w,P,L] = Hr_Type3(h);
else disp('not a linear-phase filter, check h'), return,
end
elseif all(h(1:M/2)==h(M:-1:M/2+1)); [Hr,w,P,L] = Hr_Type2(h);
elseif all(h(1:M/2)==-h(M:-1:M/2+1)); [Hr,w,P,L] = Hr_Type4(h);
else disp('not a linear-phase filter, check h'), return,
end
end

  第1小题代码

%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 7.6 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ n1 = 0; n2 = 11;
n = [n1:n2];
h1n = 0.9 .^ abs(n-5) .* cos(pi*(n-5)/12) .* ( stepseq(0,n1,n2) - stepseq(11,n1,n2) ); h1n = h1n(1:11); figure('NumberTitle', 'off', 'Name', 'Problem 7.6')
set(gcf,'Color','white');
stem([0:10], h1n); grid on;
xlabel('n'); ylabel('h1(n)'); title('Impulse Response'); [db, mag, pha, grd, w] = freqz_m(h1n, 1);
[Hr, ww, a, P] = ampl_res(h1n);
%[Hr, ww, a, P] = Hr_Type1(h1n); % Plot figure('NumberTitle', 'off', 'Name', 'Problem 7.6')
set(gcf,'Color','white'); subplot(2,2,1); plot(w/pi, db); grid on; axis([0 2 -100 10]);
xlabel('frequency in \pi units'); ylabel('Decibels'); title('Magnitude Response in dB');
set(gca,'YTickMode','manual','YTick',[-80,-40,0]);
set(gca,'YTickLabelMode','manual','YTickLabels',['80';'40';' 0']); subplot(2,2,3); plot(w/pi, mag); grid on; %axis([0 1 -100 10]);
xlabel('frequency in \pi units'); ylabel('Absolute'); title('Magnitude Response in absolute');
subplot(2,2,2); plot(w/pi, pha); grid on; %axis([0 1 -100 10]);
xlabel('frequency in \pi units'); ylabel('Rad'); title('Phase Response in Radians');
subplot(2,2,4); plot(w/pi, grd*pi/180); grid on; %axis([0 1 -100 10]);
xlabel('frequency in \pi units'); ylabel('Rad'); title('Group Delay'); figure('NumberTitle', 'off', 'Name', 'Problem 7.6')
set(gcf,'Color','white'); subplot(2,1,1); plot(ww/pi, Hr); grid on; axis([0, 1, 0, 8]);
xlabel('frequency in \pi nuits'); ylabel('Hr'); title('Amplitude Response'); subplot(2,1,2); stem([n1:n2-1], h1n); grid on;%axis([-1, M, -1.1, 1.1]);
xlabel('n'); ylabel('h1(n)'); title('Impulse Response');

  运行结果:

由上图看,很明显是非线性相位FIR的,但是其非零值(即前11个元素)构成线性相位FIR滤波器脉冲响应,如下

由上图可知,脉冲响应是第1类线性相位,其幅度响应(dB和绝对单位)、相位响应、群延迟响应如下:

该序列的零点图如下

第2小题

非线性相位FIR滤波器脉冲响应

取其前10个元素,构成第2类型Type-II型线性相位FIR滤波器脉冲响应

其零点图如下:

其余小题就不贴图了。

《DSP using MATLAB》Problem 7.6的更多相关文章

  1. 《DSP using MATLAB》Problem 7.27

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  2. 《DSP using MATLAB》Problem 7.26

    注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...

  3. 《DSP using MATLAB》Problem 7.25

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  4. 《DSP using MATLAB》Problem 7.24

    又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...

  5. 《DSP using MATLAB》Problem 7.23

    %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...

  6. 《DSP using MATLAB》Problem 7.16

    使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  7. 《DSP using MATLAB》Problem 7.15

    用Kaiser窗方法设计一个台阶状滤波器. 代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  8. 《DSP using MATLAB》Problem 7.14

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  9. 《DSP using MATLAB》Problem 7.13

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  10. 《DSP using MATLAB》Problem 7.12

    阻带衰减50dB,我们选Hamming窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

随机推荐

  1. poj 3304 Segments 线段与直线相交

    Segments Time Limit: 1000MS   Memory Limit: 65536K       Description Given n segments in the two dim ...

  2. 谈谈如何给下拉框option添加点击事件?

    我们在用到下拉列表框select时,需要对选中的<option>选项触发事件,其实<option>本身没有触发事件方法,我们只有在select里的onchange方法里触发. ...

  3. 英语发音规则---E字母常见的发音组合有哪些

    英语发音规则---E字母常见的发音组合有哪些 一.总结 一句话总结:很好记的e和5个元音字母的组合,加一个非e开头的ie e:开音节 /i:/  eve /i:v/ n. 夏娃----闭音节 /e/ ...

  4. 数字类型转换 --Python3

    数值运算符可以隐式转换输出结果的数字类型,另外,Python内置的数字类型转换函数可以显示地在数字类型之间转换: 函数 描述 int(x) 将x转换为整数,x可以是浮点数和字符串类型 float(x) ...

  5. Vue-Router + Vuex 实现单页面应用

    效果查看(一个食品安全网,大家也可以发布一些食品安全的见闻,尽举手之劳): 源代码:https://pan.baidu.com/s/1i43H3LV 如果想要服务器端代码可以在评论里说明一下 利用vu ...

  6. leetcode-algorithms 目录

    leetcode算法目录 题号 链接 难度等级 36 leetcode-algorithms-36 Valid Sudoku medium 35 leetcode-algorithms-35 Sear ...

  7. ThinkPHP5.0源码学习之执行应用

    一.应用启动 在/thinkphp/start.php文件中,用一句代码App::run()->send();实现应用的启动. // 执行应用 App::run()->send();   ...

  8. Php的基本语法学习

    1.php语法 当 PHP 解析一个文件时,会寻找开始和结束标记,标记告诉 PHP 开始和停止解释其中的代码. 1)标记语法 是以<?php 开头,?> 结束,相当于html标签的开始标签 ...

  9. 禁用cookie后的方法

    保存session id的方式可以采用cookie,这样在交互过程中浏览器可以自动的按照规则把这个标识发送给 服务器.一般这个cookie的名字都是类似于SEEESIONID.但cookie可以被人为 ...

  10. .net core部署到Ubuntu碰到的问题

    数据库连接的时候,会报错“MySql.Data.MySqlClient.MySqlException:“The host localhost does not support SSL connecti ...