《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 ...
随机推荐
- phpcms v9 栏目伪静态完全自定义为栏目英文目录名
1,后台增加url规则,增加后.导航上,或分页号上,会自动替换为静态的样式.类似www.abc.com/news/2/ 2表示页码 phpcms v9 的后台扩展,url规则,添加两个规则, 一个是名 ...
- 二、nginx 安装目录详解
rpm -ql nginx 路径 类型 介绍 /etc/logrotate.d/nginx 配置文件 Nginx 日志轮转,用于logrotate服务日志切割 /etc/nginx /etc/ng ...
- 关于 Token,你应该知道的十件事
转自:http://ju.outofmemory.cn/entry/134189 原文是一篇很好的讲述 Token 在 Web 应用中使用的文章,而这是我和 Special 合作翻译的译文. 1. T ...
- (新)自己动手写ORM框架(1)-增删查改的使用
之前写过一个系列文章自己动手写ORM框架,经过在多个项目的中的使用,对这套代码进行了许多改进,下面是使用方法: 新增学员信息代码预览: DBHelper db = DBHelper.getInstan ...
- proxy-target-class 作用
该属性值默认为false,表示使用JDK动态代理织入增强;当值为true时,表示使用CGLib动态代理织入增强;但是,即使设置为false,如果目标类没有生命接口, 则Spring将自动使用CGLib ...
- S16课件
Python之路,Day1 - Python基础1 介绍.基本语法.流程控制 Python之路,Day2 - Python基础2 列表.字典.集合 Python之路,Day3 - Python基础3 ...
- Shell test 命令,Shell 输入/输出重定向
一.Shell test 命令 Shell中的 test 命令用于检查某个条件是否成立,它可以进行数值.字符和文件三个方面的测试. 数值测试 参数 说明 -eq 等于则为真 -ne 不等于则为真 -g ...
- pxe自动安装
首先我们要用到的linux的桌面模式,没有桌面模式的请自觉安装.注意要关闭防火墙 需要的支持环境,dhcp,tftp,vsftp. 1.先创建ftp的共享光盘目录 mkdir -p /var/ftp/ ...
- LeetCode OJ:N-Queens(N皇后问题)
Given an integer n, return all distinct solutions to the n-queens puzzle. Each solution contains a d ...
- CSS3径向渐变linear-gradient
语法: 选择器{ background:linear-gradien(线性渐变的方向,起点颜色,终点颜色): } 第一个参数:[可选参数,默认从上到下] 线性渐变的方向:top,bottom,left ...