《DSP using MATLAB》示例Example 8.26
代码:
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Exameple 8.26 \n\n'); time_stamp = datestr(now, 31);
[wkd1, wkd2] = weekday(today, 'long');
fprintf(' Now is %20s, and it is %8s \n\n', time_stamp, wkd2);
%% ------------------------------------------------------------------------ % Digital Lowpass Filter Specifications:
wplp = 0.2*pi; % digital passband freq in rad
wslp = 0.3*pi; % digital stopband freq in rad
Rp = 1; % passband ripple in dB
As = 15; % stopband attenuation in dB % Analog prototype specifications: Inverse Mapping for frequencies
T = 1; Fs = 1/T; % set T = 1
OmegaP = (2/T)*tan(wplp/2); % Prewarp(Cutoff) prototype passband freq
OmegaS = (2/T)*tan(wslp/2); % Prewarp(cutoff) prototype stopband freq % Analog Chebyshev-1 Prototype Filter Calculations:
[cs, ds] = afd_chb1(OmegaP, OmegaS, Rp, As); % Bilinear transformation to obtain digital lowpass:
[blp, alp] = bilinear(cs, ds, Fs); % Digital Highpass Filter Design:
wphp = 0.6*pi; % Digital HP cutoff freq, passband edge freq % LP-to-HP frequency-band transfromation:
alpha = -(cos((wplp+wphp)/2))/(cos((wplp-wphp)/2))
Nz = -[alpha, 1]; Dz = [1, alpha]; [bhp, ahp] = zmapping(blp, alp, Nz, Dz); [C, B, A] = dir2cas(bhp, ahp) % Calculation of Frequency Response:
[dblp, maglp, phalp, grdlp, wwlp] = freqz_m(blp, alp);
[dbhp, maghp, phahp, grdhp, wwhp] = freqz_m(bhp, ahp); %% -----------------------------------------------------------------
%% Plot
%% ----------------------------------------------------------------- figure('NumberTitle', 'off', 'Name', 'Exameple 8.26a')
set(gcf,'Color','white');
M = 1; % Omega max subplot(2,2,1); plot(wwlp/pi, maglp); axis([0, M, 0, 1.2]); grid on;
xlabel(' frequency in \pi units'); ylabel('|H|'); title('Lowpass Filter Magnitude Response');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.2, 0.3, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.1778, 0.8913, 1]); subplot(2,2,2); plot(wwlp/pi, dblp); axis([0, M, -30, 2]); grid on;
xlabel(' frequency in \pi units'); ylabel('Decibels'); title('Lowpass Filter Magnitude in dB');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.2, 0.3, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-30, -15, -1, 0]); subplot(2,2,3); plot(wwhp/pi, maghp); axis([0, M, 0, 1.2]); grid on;
xlabel(' frequency in \pi units'); ylabel('|H|'); title('Highpass Filter Magnitude Response');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.6, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.8913, 1]); subplot(2,2,4); plot(wwhp/pi, dbhp); axis([0, M, -30, 2]); grid on;
xlabel(' frequency in \pi units'); ylabel('Decibels'); title('Highpass Filter Magnitude in dB');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.6, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-30, -1, 0]); figure('NumberTitle', 'off', 'Name', 'Exameple 8.26b')
set(gcf,'Color','white'); subplot(2,2,1); plot(wwlp/pi, phalp/pi); axis([0, M, -1.1, 1.1]); grid on;
xlabel('frequency in \pi nuits'); ylabel('radians in \pi units'); title('Lowpass Filter Phase Response');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.2, 0.3, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-1:1:1]); subplot(2,2,2); plot(wwlp/pi, grdlp); axis([0, M, 0, 15]); grid on;
xlabel('frequency in \pi units'); ylabel('Samples'); title('Lowpass Filter Group Delay');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.2, 0.3, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0:5:15]); subplot(2,2,3); plot(wwhp/pi, phahp/pi); axis([0, M, -1.1, 1.1]); grid on;
xlabel('frequency in \pi nuits'); ylabel('radians in \pi units'); title('Highpass Filter Phase Response');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.6, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-1:1:1]); subplot(2,2,4); plot(wwhp/pi, grdhp); axis([0, M, 0, 15]); grid on;
xlabel('frequency in \pi units'); ylabel('Samples'); title('Highpass Filter Group Delay');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.6, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0:5:15]);
运行结果:
《DSP using MATLAB》示例Example 8.26的更多相关文章
- 《DSP using MATLAB》Problem 7.26
注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 8.26
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- DSP using MATLAB 示例Example3.21
代码: % Discrete-time Signal x1(n) % Ts = 0.0002; n = -25:1:25; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*a ...
- DSP using MATLAB 示例 Example3.19
代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Discrete-time Signa ...
- DSP using MATLAB示例Example3.18
代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Continuous-time Fou ...
- DSP using MATLAB 示例Example3.23
代码: % Discrete-time Signal x1(n) : Ts = 0.0002 Ts = 0.0002; n = -25:1:25; nTs = n*Ts; x1 = exp(-1000 ...
- DSP using MATLAB 示例Example3.22
代码: % Discrete-time Signal x2(n) Ts = 0.001; n = -5:1:5; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*abs(nT ...
- DSP using MATLAB 示例Example3.17
- DSP using MATLAB示例Example3.16
代码: b = [0.0181, 0.0543, 0.0543, 0.0181]; % filter coefficient array b a = [1.0000, -1.7600, 1.1829, ...
- DSP using MATLAB 示例 Example3.15
上代码: subplot(1,1,1); b = 1; a = [1, -0.8]; n = [0:100]; x = cos(0.05*pi*n); y = filter(b,a,x); figur ...
随机推荐
- 最新版本的Struts2+Spring4+Hibernate4三大框架整合(截止2014-10-15,提供源码下载)
一. 项目名称:S2316S411H436 项目原型:Struts2.3.16 + Spring4.1.1 + Hibernate4.3.6 + Quartz2.2.1 源代码下载地址: 基本版:ht ...
- w3c标准盒模型与IE传统模型的区别
一.盒子模型(box model) 在HTML文档中的每个元素被描绘为矩形盒子.确定其大小,属性——比如颜色.背景.边框,及其位置是渲染引擎的目标. CSS下这些矩形盒子由标准盒模型描述.这个模型描述 ...
- tags
运行tags在你的.vimrc 中加一个路径,set tags=/home/lh/1407k/arm/tags 注意此文件下的东西要注销必须用“执行一个ctags -R *;ctrl + ]过去,ct ...
- WPF TextBox 获得焦点后,文本框中的文字全选中
textbox.GotFocus 事件处理 Textbox.SelectAll() 是不行的, 这样处理会发生的情况是: 1) textbox1 当前没有焦点, 内容为 someText. 2) 鼠标 ...
- 使用jenkins自动构建docker容器范例
1.登录Jenkins,新建一个自由风格的软件项目. 2.源码管理选择git,并添加Repository URL.Credentials 3.构建选择 Execute Shell,命令如下: dock ...
- day18 分页+form验证+中间件
参考课件: http://www.cnblogs.com/wupeiqi/articles/6144178.html http://www.cnblogs.com/wupeiqi/articles/5 ...
- 【hive】在alter修改元数据的时候报错 mismatched input 'xxxxx' expecting KW_EXCHANGE
目的:修改表某个字段属性 语句: 报错信息 错误原因: 在HiveQL中,alter命令不使用与create或select相同的语义 ; 具体来说,您不能使用“ALTER DATABASE.TABLE ...
- nfs的简单搭建与原理
nfs最大的缺点是单点,只能一对一nfs统称存储服务器,放视频图片之类的东西,所以服务器的容量很大数字都是放在数据库里边的, nfs的挂载原理 客户端怎么知道服务端的开启端口? 找rpcbind,再启 ...
- (转)Pig 重写加载函数和存储函数UDF
pig自带的pigstorage不能指定行分隔符,所以自己重写了一个简单的UDF类,可以指定列和行的分隔符,之前研究过的简单的, http://blog.csdn.net/ruishenh/artic ...
- gradle-wrapper.properties中各属性的含义
gradle-wrapper.properties中各属性的含义 1. gradle-wrapper.properties 每一个用gradle编译的工程,都会有一个gradle\wrapper目录. ...