《DSP using MATLAB》Problem 8.22
时光飞逝,亲朋会一个一个离我们远去,孤独漂泊一阵子后,我们自己也要离开,
代码:
%% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 8.22 \n\n');banner(); %% ------------------------------------------------------------------------% ------------------------------- % ω = ΩT = 2πF/fs % Digital Filter Specifications: % ------------------------------- wp = 0.4*pi; % digital passband freq in rad/sec ws = 0.6*pi; % digital stopband freq in rad/sec Rp = 0.5; % passband ripple in dB As = 50; % stopband attenuation in dBRipple = 10 ^ (-Rp/20) % passband ripple in absolute Attn = 10 ^ (-As/20) % stopband attenuation in absolute% Analog prototype specifications: Inverse Mapping for frequencies T = 2; % set T = 1 Fs = 1/T; OmegaP = wp/T; % prototype passband freq OmegaS = ws/T; % prototype stopband freq% Analog Butterworth Prototype Filter Calculation: [cs, ds] = afd_butt(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);% Calculation of Impulse Response: [ha, x, t] = impulse(cs, ds);% Impulse Invariance Transformation: [b, a] = imp_invr(cs, ds, T); [C, B, A] = dir2par(b, a)% Calculation of Frequency Response: [db, mag, pha, grd, ww] = freqz_m(b, a);%% ----------------------------------------------------------------- %% Plot %% ----------------------------------------------------------------- figure('NumberTitle', 'off', 'Name', 'Problem 8.22 Analog Butterworth lowpass') set(gcf,'Color','white'); M = 1; % Omega maxsubplot(2,2,1); plot(ww_s, mag_s/T); grid on; axis([-M, M, 0, 1.2]); xlabel(' Analog frequency in \pi units'); ylabel('|H|'); title('Magnitude in Absolute'); set(gca, 'XTickMode', 'manual', 'XTick', [-0.3, -0.2, 0, 0.2, 0.3, 0.4, 0.6]); set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.0032, 0.5, 0.9441, 1]);subplot(2,2,2); plot(ww_s, 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.3, -0.2, 0, 0.4, 0.6]); set(gca, 'YTickMode', 'manual', 'YTick', [-65, -50, -1, 0]); set(gca,'YTickLabelMode','manual','YTickLabel',['65';'50';' 1';' 0']);subplot(2,2,3); plot(ww_s, pha_s/pi); grid on; axis([-M, M, -1.2, 1.2]); xlabel('Analog frequency in \pi nuits'); ylabel('radians'); title('Phase Response'); set(gca, 'XTickMode', 'manual', 'XTick', [-0.3, -0.2, 0, 0.4, 0.6]); 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.22 Digital Butterworth lowpass') set(gcf,'Color','white'); M = 2; % Omega maxsubplot(2,2,1); plot(ww/pi, mag); axis([0, M, 0, 1.2]); grid on; xlabel(' frequency in \pi units'); ylabel('|H|'); title('Magnitude Response'); set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.4, 0.6, 1.0, M]); set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.0032, 0.5, 0.9441, 1]);subplot(2,2,2); plot(ww/pi, pha/pi); axis([0, M, -1.1, 1.1]); grid on; xlabel('frequency in \pi nuits'); ylabel('radians in \pi units'); title('Phase Response'); set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.4, 0.6, 1.0, M]); set(gca, 'YTickMode', 'manual', 'YTick', [-1:1:1]);subplot(2,2,3); plot(ww/pi, db); axis([0, M, -100, 10]); grid on; xlabel('frequency in \pi units'); ylabel('Decibels'); title('Magnitude in dB '); set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.4, 0.6, 1.0, M]); set(gca, 'YTickMode', 'manual', 'YTick', [-70, -50, -1, 0]); set(gca,'YTickLabelMode','manual','YTickLabel',['70';'50';' 1';' 0']);subplot(2,2,4); plot(ww/pi, grd); grid on; %axis([0, M, 0, 35]); xlabel('frequency in \pi units'); ylabel('Samples'); title('Group Delay'); set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.4, 0.6, 1.0, M]); %set(gca, 'YTickMode', 'manual', 'YTick', [0:5:35]);figure('NumberTitle', 'off', 'Name', 'Problem 8.22 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.22 Imp & Freq Response') set(gcf,'Color','white'); t = [0:0.01:80]; subplot(2,1,1); impulse(cs,ds,t); grid on; % Impulse response of the analog filter axis([0,80,-0.2,0.3]);hold onn = [0:1:80/T]; hn = filter(b,a,impseq(0,0,80/T)); % Impulse response of the digital filter stem(n*T,hn); xlabel('time in sec'); title ('Impulse Responses'); 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*Fs,'b+', wwz/(2*pi)*Fs,magz,'r'); grid on;xlabel('frequency in Hz'); title('Magnitude Responses'); ylabel('Magnitude'); text(-0.3,0.15,'Analog filter'); text(0.4,0.55,'Digital filter');
运行结果:
通带、阻带绝对指标
模拟原型butterworth低通滤波器直接形式系数
模拟原型butterworth低通滤波器串联形式系数
脉冲响应不变法,模拟低通转换成数字低通,并联形式系数
转载于:https://www.cnblogs.com/ky027wh-sx/p/11162249.html
《DSP using MATLAB》Problem 8.22相关推荐
- 《DSP using MATLAB》Problem 5.7
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 6.24
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 6.12
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 6.20
先放子函数: function [C, B, A, rM] = dir2fs_r(h, r);% DIRECT-form to Frequency Sampling form conversion % ...
- 《DSP using MATLAB》Problem 7.26
注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 6.6
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.36
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.16
使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 8.1
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
最新文章
- 下列属于PHP的数据类型的是,中国大学MOOC: 下列不属于PHP数据类型的是( )。...
- 拨出网线后,网卡IP丢失
- python:数据操作小技巧
- 前OnePlus视觉设计师蔡孝永:视觉设计师都在想些什么?
- linux删除文件夹和文件
- php读取ds18b20,DS18B20_单总线协议
- 【转】在Windows中搭建iPhone开发环境
- LeetCode 34 Search for a Range(搜索范围)
- c语言乐谱编辑软件怎么用的,雅乐简谱这个软件怎么使用?
- Mac 修改移动硬盘图标,U盘图标
- torch.sort
- SpringBoot实现分页查询
- ubuntu下安装windows adobeflash播放器插件
- 【莹伙丛】手把手教你:Gradle 安装及配置
- go语言上手-HTTP 文件服务器
- 各厂内推整理 (新增宇宙条)| 第四期
- 【Elasticsearch】windows 10安装Elasticsearch和Kibana
- 电子计算机女生就业方向,计算机专业的女生就业方向有哪些
- 基于全过程通道相关像素值顺序的彩色图像可逆数据隐藏
- 中华会计网吉安培训中心
热门文章
- 高德地图自定义Marker显示文字
- 笛卡尔积 php,PHP笛卡尔积实现算法示例
- CTECH_EVS_AND_MVS_V6.6
- 【站长图卦】你被逼过婚吗
- php 正则验证手机号和电话
- LayUI 数据表格 分页失效
- c语言中215 10等于,云南铜业高级技工学校2014-215学年第一学期《电气控制与PLC》期中考试试卷B卷(答案)...
- 视音频编解码基本术语及解释
- 搭搭云-超级应用平台 与JNPF Java多用户商城系统源码 最新版3.4.7源码折扣
- 6630变成QQ摄像头 可用数据线或蓝牙