《DSP using MATLAB》Problem 8.32

代码:
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 8.32 \n\n'); banner();
%% ------------------------------------------------------------------------ % -------------------------------------
% Ω=(2/T)tan(ω/2)
% ω=2*[atan(ΩT/2)]
% Digital Filter Specifications:
% -------------------------------------
wp = 0.3*pi; % digital passband freq in rad
ws = 0.4*pi; % digital stopband freq in rad
Rp = 0.25; % passband ripple in dB
As = 50; % stopband attenuation in dB Ripple = 10 ^ (-Rp/20) % passband ripple in absolute
Attn = 10 ^ (-As/20) % stopband attenuation in absolute % Analog prototype specifications: Inverse Mapping for frequencies
T = 1; % set T = 1
Fs = 1/T;
OmegaP = (2/T)*tan(wp/2) % prototype passband freq
OmegaS = (2/T)*tan(ws/2) % prototype stopband freq % Analog Elliptic Prototype Filter Calculation:
[cs, ds] = afd_elip(OmegaP, OmegaS, Rp, As); % Calculation of second-order sections:
fprintf('\n***** Cascade-form in s-plane: START *****\n');
[CS, BS, AS] = sdir2cas(cs, ds)
fprintf('\n***** Cascade-form in s-plane: END *****\n'); % Calculation of Frequency Response:
[db_s, mag_s, pha_s, ww_s] = freqs_m(cs, ds, 0.5*pi/T); % Calculation of Impulse Response:
[ha, x, t] = impulse(cs, ds); % Impulse Invariance Transformation:
%[b, a] = imp_invr(cs, ds, T); % Bilinear Transformation
[b, a] = bilinear(cs, ds, Fs)
[C, B, A] = dir2cas(b, a) % Calculation of Frequency Response:
[db, mag, pha, grd, ww] = freqz_m(b, a); %% -----------------------------------------------------------------
%% Plot
%% -----------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Problem 8.32 Analog Elliptic lowpass')
set(gcf,'Color','white');
M = 1.0; % Omega max subplot(2,2,1); plot(ww_s/pi, mag_s); grid on; %axis([-10, 10, 0, 1.2]);
xlabel(' Analog frequency in \pi units'); ylabel('|H|'); title('Magnitude in Absolute');
set(gca, 'XTickMode', 'manual', 'XTick', [-0.4625, -0.3244, 0, 0.3244, 0.4625]);
set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.0032, 0.9716, 1.0, 1.5]); subplot(2,2,2); plot(ww_s/pi, db_s); grid on; %axis([0, M, -50, 10]);
xlabel('Analog frequency in \pi units'); ylabel('Decibels'); title('Magnitude in dB ');
set(gca, 'XTickMode', 'manual', 'XTick', [-0.4625, -0.3244, 0, 0.3244, 0.417, 0.458, 0.4625]);
set(gca, 'YTickMode', 'manual', 'YTick', [-50, -1, 0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['50';' 1';' 0']); subplot(2,2,3); plot(ww_s/pi, pha_s/pi); grid on; %axis([-10, 10, -1.2, 1.2]);
xlabel('Analog frequency in \pi nuits'); ylabel('radians'); title('Phase Response');
set(gca, 'XTickMode', 'manual', 'XTick', [-0.4625, -0.3244, 0, 0.3244, 0.4625]);
set(gca, 'YTickMode', 'manual', 'YTick', [-1:0.5:1]); subplot(2,2,4); plot(t, ha); grid on; %axis([0, 30, -0.05, 0.25]);
xlabel('time in seconds'); ylabel('ha(t)'); title('Impulse Response'); figure('NumberTitle', 'off', 'Name', 'Problem 8.32 Digital Elliptic lowpass by bilinear')
set(gcf,'Color','white');
M = 2; % Omega max subplot(2,2,1); plot(ww/pi, mag); axis([0, M, 0, 1.2]); grid on;
xlabel(' Digital frequency in \pi units'); ylabel('|H|'); title('Magnitude Response');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, 1.6, 1.7, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.0032, 0.9716, 1]); subplot(2,2,2); plot(ww/pi, pha/pi); axis([0, M, -1.1, 1.1]); grid on;
xlabel('Digital frequency in \pi nuits'); ylabel('radians in \pi units'); title('Phase Response');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, 1.6, 1.7, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-1:1:1]); subplot(2,2,3); plot(ww/pi, db); axis([0, M, -80, 10]); grid on;
xlabel('Digital frequency in \pi units'); ylabel('Decibels'); title('Magnitude in dB ');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.37, 0.4, 1.6, 1.7, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-60, -50, -1, 0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['60';'50';' 1';' 0']); subplot(2,2,4); plot(ww/pi, grd); grid on; %axis([0, M, 0, 35]);
xlabel('Digital frequency in \pi units'); ylabel('Samples'); title('Group Delay');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, 1.6, 1.7, M]);
%set(gca, 'YTickMode', 'manual', 'YTick', [0:5:35]); figure('NumberTitle', 'off', 'Name', 'Problem 8.32 Pole-Zero Plot')
set(gcf,'Color','white');
zplane(b,a);
title(sprintf('Pole-Zero Plot'));
%pzplotz(b,a); % ----------------------------------------------
% Calculation of Impulse Response
% ----------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Problem 8.32 Imp & Freq Response')
set(gcf,'Color','white');
t = [0:0.01:90]; subplot(2,1,1); impulse(cs,ds,t); grid on; % Impulse response of the analog filter
axis([0,90,-0.2,0.3]);hold on n = [0:1:90/T]; hn = filter(b,a,impseq(0,0,90/T)); % Impulse response of the digital filter
stem(n*T,hn); xlabel('time in sec'); title (sprintf('Impulse Responses T=%2d',T));
hold off % Calculation of Frequency Response:
[dbs, mags, phas, wws] = freqs_m(cs, ds, 2*pi/T); % Analog frequency s-domain [dbz, magz, phaz, grdz, wwz] = freqz_m(b, a); % Digital z-domain %% -----------------------------------------------------------------
%% Plot
%% ----------------------------------------------------------------- subplot(2,1,2); plot(wws/(2*pi), mags/T,'b', wwz/(2*pi*T), magz, 'r'); grid on; xlabel('frequency in Hz'); title('Magnitude Responses'); ylabel('Magnitude'); text(-0.8,0.15,'Analog filter', 'Color', 'b'); text(0.8,0.4,'Digital filter', 'Color', 'r');
运行结果:
这里主要放双线性变化法的代码。
通带、阻带绝对指标,模拟滤波器截止频率指标,

模拟Elliptic原型低通滤波器,系统函数串联形式的系数

采用双线性变换法,得到数字Elliptic低通滤波器,系统函数直接形式的系数,转换成串联形式的系数

模拟Elliptic原型低通滤波器,其幅度谱、相位谱和脉冲响应

采用双线性变换法(bilinear)得到数字Elliptic低通滤波器,其幅度谱、相位谱和群延迟响应

数字Elliptic低通系统函数零极点图

模拟原型和数字低通的脉冲响应对比,可见双线性变换法不保留脉冲响应的形态。

使用MATLAB自带ellip函数的运算结果这里就不写了,只放张幅度谱、相位谱和群延迟响应的图,可见和双线性变换法得到的结果相比,区别不大。

《DSP using MATLAB》Problem 8.32的更多相关文章
- 《DSP using MATLAB》Problem 5.32
代码: function [y] = ovrlpadd_v3(x, h, N) %% Overlap-Add method of block convolution %% -------------- ...
- 《DSP using MATLAB》Problem 7.32
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 6.8
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 5.28
昨晚手机在看X信的时候突然黑屏,开机重启都没反应,今天维修师傅说使用时间太长了,还是买个新的吧,心疼银子啊! 这里只放前两个小题的图. 代码: 1. %% ++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 5.22
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% O ...
- 《DSP using MATLAB》Problem 5.10
代码: 第1小题: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Out ...
- 《DSP using MATLAB》Problem 7.27
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.26
注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.25
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
随机推荐
- Java oop创建自定义异常
package com.test; /** *不管是在方法定义时就使用try catch,还是在定义方法时将异常抛出在调用方法时使用try catch都能达到效果 * */public class M ...
- linux 服务器安装mysql5.6
1.移除CentOS默认的mysql-libs: whereis mysql 2.为了避免冲突,先移除CenttOS上默认的mysql-libs: yum remove mysql-libs 3.然后 ...
- 三角形的实现和盒模型、层模型、浮动模型、定位、权重、margin问题
相邻的border会平分所占的区域,出现一个斜线, .my_triangle{ width: 10px; height: 10px; background-color: blue; border-wi ...
- CF421D Bug in Code
题意:n个人每人选择了另外不相同的两个人.问有多少对(x,y)使得这n个人中至少有p个选择了至少其中之一? 标程:那就不写了吧. 题解:容斥 统计Ax表示有多少个人选择了x. 一般来说有Ax+Ay&g ...
- java实现单链表增删改查
package 数据结构算法.链表; /* *定义节点 * 链表由节点构成 */ public class Node<E> { private E e; //数据data private ...
- C++在#include命令中,用〈 〉和“”有什么区别
使用尖括号表示在包含文件目录中去查找(包含目录是由用户在设置环境时设置的),而不在源文件目录去查找: 使用双引号则表示首先在当前的源文件目录中查找,若未找到才到包含目录中去查找.
- echarts折线区域图
一.使用场景 当舒张压和收缩压超过或低于他们对应的范围时,折线应该给与不同颜色.两个指标对应的范围也要填充不同的颜色. 二.实现方案 主要使用了echarts中的visualMap,series.ma ...
- 20175323《Java程序设计》第四周学习总结
教材学习内容总结 我用幕布记录学习过程和思路,下面是我这章的知识框架总结https://mubu.com/doc/ffMhY6FVc0 教材学习中的问题和解决过程 问题1:教材121页的例六Examp ...
- vue.js+web storm安装及第一个vue.js
小白还是自己写一遍吧 1.下载node.js https://nodejs.org/en/download/ 2.安装淘宝镜像(类似于阿里云的maven中央仓库镜像) 安装时间有点长 安装命令:npm ...
- 转:C语言中volatile关键字的作用 专家博客
源地址:http://blog.csdn.net/tigerjibo/article/details/7427366 一.前言 1.编译器优化介绍: 由于内存访问速度远不及CPU处理速度,为提高机器整 ...