参照Example7.27,因为0.1π=2πf1   f1=0.05,0.9π=2πf2   f2=0.45

所以0.1π≤ω≤0.9π,0.05≤|H|≤0.45

代码:

%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 7.31 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ f = [0 0.1 0.9 1]; % in w/pi units
m = [0 0.05 0.45 0]; % Magnitude values M = 25; % length of filter
N = M - 1; % Nth-order
h = firpm(N, f, m, 'differentiator');
%h
[db, mag, pha, grd, w] = freqz_m(h, [1]); [Hr, ww, c, L] = Hr_Type3(h);
%[Hr,omega,P,L] = ampl_res(h); l = 0:M-1;
%% -------------------------------------------------
%% Plot
%% -------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Problem 7.31')
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi, db); grid on; axis([0 2 -90 10]);
set(gca,'YTickMode','manual','YTick',[-60,-40,-20,0])
set(gca,'YTickLabelMode','manual','YTickLabel',['60';'40';'20';' 0']);
set(gca,'XTickMode','manual','XTick',[0,0.1,0.9,1,1.1,1.9,2]);
xlabel('frequency in \pi units'); ylabel('Decibels'); title('Magnitude Response in dB'); 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');
set(gca,'XTickMode','manual','XTick',[0,0.1,0.9,1,1.1,1.9,2]);
set(gca,'YTickMode','manual','YTick',[0,1.0,2.0]); 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.31')
set(gcf,'Color','white'); subplot(2,2,1); stem(l, h); axis([-1, M, -0.6, 0.5]); grid on;
xlabel('n'); ylabel('h(n)'); title('Actual Impulse Response, M=25');
set(gca, 'XTickMode', 'manual', 'XTick', [0,12,25]);
set(gca, 'YTickMode', 'manual', 'YTick', [-0.6:0.2:0.6]); subplot(2,2,3); plot(w/pi, db); axis([0, 1, -80, 10]); grid on;
xlabel('frequency in \pi units'); ylabel('Decibels'); title('Magnitude Response in dB ');
set(gca,'XTickMode','manual','XTick',f)
set(gca,'YTickMode','manual','YTick',[-60,-40,-20,0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['60';'40';'20';' 0']); subplot(2,2,4); plot(ww/pi, Hr); axis([0, 1, -0.2, 1.5]); grid on;
xlabel('frequency in \pi nuits'); ylabel('Hr(w)'); title('Amplitude Response'); n = [0:1:100];
x = 3*sin(0.25*pi*n);
y = filter(h,1,x);
y_chk = 0.75*cos(0.25*pi*n); figure('NumberTitle', 'off', 'Name', 'Problem 7.31 x(n)')
set(gcf,'Color','white');
subplot(2,1,1); stem([0:M-1], h); axis([0 M-1 -0.5 0.5]); grid on;
xlabel('n'); ylabel('h(n)'); title('Actual Impulse Response, M=25'); subplot(2,1,2); stem(n, x); axis([0 100 0 3]); grid on;
xlabel('n'); ylabel('x(n)'); title('Input sequence'); figure('NumberTitle', 'off', 'Name', 'Problem 7.31 y(n) and y_chk(n)')
set(gcf,'Color','white');
subplot(2,1,1); stem(n, y); axis([0 100 -1 1]); grid on;
xlabel('n'); ylabel('y(n)'); title('Output sequence'); subplot(2,1,2); stem(n, y_chk); axis([0 100 -1 1]); grid on;
xlabel('n'); ylabel('y\_chk(n)'); title('Output sequence'); % ---------------------------
% DTFT of x
% ---------------------------
MM = 500;
[X, w1] = dtft1(x, n, MM);
[Y, w1] = dtft1(y, n, MM); magX = abs(X); angX = angle(X); realX = real(X); imagX = imag(X);
magY = abs(Y); angY = angle(Y); realY = real(Y); imagY = imag(Y); figure('NumberTitle', 'off', 'Name', 'Problem 7.31 DTFT of x(n)')
set(gcf,'Color','white');
subplot(2,2,1); plot(w1/pi,magX); grid on; %axis([0,2,0,15]);
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude |X|');
subplot(2,2,3); plot(w1/pi, angX/pi); grid on; axis([0,2,-1,1]);
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); subplot('2,2,2'); plot(w1/pi, realX); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,2,4'); plot(w1/pi, imagX); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary'); figure('NumberTitle', 'off', 'Name', 'Problem 7.31 DTFT of y(n)')
set(gcf,'Color','white');
subplot(2,2,1); plot(w1/pi,magY); grid on; %axis([0,2,0,15]);
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude |Y|');
subplot(2,2,3); plot(w1/pi, angY/pi); grid on; axis([0,2,-1,1]);
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); subplot('2,2,2'); plot(w1/pi, realY); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,2,4'); plot(w1/pi, imagY); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary'); figure('NumberTitle', 'off', 'Name', 'Problem 7.31 Magnitude Response')
set(gcf,'Color','white');
subplot(1,2,1); plot(w1/pi,magX); grid on; %axis([0,2,0,15]);
title('Magnitude Part of Input');
xlabel('frequency in \pi units'); ylabel('Magnitude |X|');
subplot(1,2,2); plot(w1/pi,magY); grid on; %axis([0,2,0,15]);
title('Magnitude Part of Output');
xlabel('frequency in \pi units'); ylabel('Magnitude |Y|');

  运行结果:

根据线性相位FIR性质,differentiator为第3类线性相位FIR,下图为脉冲响应、幅度谱和振幅谱。

脉冲响应和输入序列

下图分别用卷积法和数学求导数方法得到的输出,

各自求其离散时间傅氏变换DTFT,得

两种求微分结果幅度谱对比,可以看出:

1、设计滤波器卷积输入,输出的0.5π频率附近出现能量,数学求法没有;

2、设计滤波器卷积输入,幅度较数学求法小(能量有损失?);

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

  1. 《DSP using MATLAB》Problem 5.31

    第3小题: 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Out ...

  2. 《DSP using MATLAB》Problem 8.31

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  3. 《DSP using MATLAB》Problem 7.26

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

  4. 《DSP using MATLAB》Problem 7.25

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

  5. 《DSP using MATLAB》Problem 7.24

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

  6. 《DSP using MATLAB》Problem 6.12

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

  7. 《DSP using MATLAB》Problem 6.10

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

  8. 《DSP using MATLAB》Problem 2.7

    1.代码: function [xe,xo,m] = evenodd_cv(x,n) % % Complex signal decomposition into even and odd parts ...

  9. 《DSP using MATLAB》Problem 2.6

    1.代码 %% ------------------------------------------------------------------------ %% Output Info abou ...

随机推荐

  1. System.Math.cs

    ylbtech-System.Math.cs 1. 程序集 mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c56193 ...

  2. vue-router 基本操作

    安装 vue-router 在命令行中进入 vue 的项目目录里,运行命令 npm install vue-router --save 来进行安装   npm install vue-router - ...

  3. Han Xin and His Troops(扩展中国剩余定理 Python版)

    Han Xin and His Troops(扩展中国剩余定理 Python版) 题目来源:2019牛客暑期多校训练营(第十场) D - Han Xin and His Troops 题意:   看标 ...

  4. 在任务管理中显示进程ID号

  5. ReadyAPI创建功能测试的多种方法

    原文:ReadyAPI创建功能测试的多种方法 声明:如果你想转载,请标明本篇博客的链接,请多多尊重原创,谢谢! 本篇使用的 ReadyAPI版本是2.5.0 在ReadyAPI中有多种方法可以创建功能 ...

  6. Nginx 教程 1:基本概念

    简介 我们会告诉你 Nginx 是如何工作的,其背后的概念有哪些,以及如何优化它以提升应用程序的性能.还会告诉你如何安装,如何启动.运行. 这个教程包括三节: 基础概念——你可以了解命令(direct ...

  7. 获取url指定参数值(js/vue)

    function getParam(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&am ...

  8. tensorflow识别验证码(1)-tensorflow安装,验证码生成

    什么是TensorFlow?  TensorFlow是Google开发的一款神经网络的Python外部的结构包, 也是一个采用数据流图来进行数值计算的开源软件库.TensorFlow 让我们可以先绘制 ...

  9. python requests 高级用法

    高级用法 本篇文档涵盖了 Requests 的一些高级特性. 会话对象 会话对象让你能够跨请求保持某些参数.它也会在同一个 Session 实例发出的所有请求之间保持 cookie, 期间使用 url ...

  10. 下面分享一下RHEL/CentOS7 安装图形化桌面详细图解

    Linux是一个多任务的多用户的操作系统,好多linux爱好者在安装完linux后经常遇到一个问题——没有图形化桌面(http://www.xcmnyy.com)今天小编在安装RHEL7的时候,一步留 ...