代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Exameple 9.8 \n\n'); time_stamp = datestr(now, 31);
[wkd1, wkd2] = weekday(today, 'long');
fprintf(' Now is %20s, and it is %7s \n\n', time_stamp, wkd2);
%% ------------------------------------------------------------------------ I = 5; Rp = 0.1; As = 30; wp = pi/I; ws = wp+pi*0.12;
[delta1, delta2] = db2delta(Rp, As); weights = [delta2/delta1, 1];
F = [0, wp, ws, pi]/pi; A = [I, I, 0, 0];
h = firpm(30, F, A, weights); n = [0:length(h)-1];
[Hr, w, a, L] = Hr_Type1(h); Hr_min = min(Hr); w_min = find(Hr == Hr_min);
H = abs(freqz(h, 1, w)); Hdb = 20*log10(H/max(H)); min_attn = Hdb(w_min); %% -----------------------------------------------------------------
%% Plot
%% -----------------------------------------------------------------
Hf1 = figure('units', 'inches', 'position', [1, 1, 8, 6], ...
'paperunits', 'inches', 'paperposition', [0, 0, 6, 4], ...
'NumberTitle', 'off', 'Name', 'Exameple 9.8');
set(gcf,'Color','white'); TF = 10; subplot(2, 2, 1);
Hs1 = stem(n, h, 'filled'); set(Hs1, 'markersize', 2);
axis([-1, length(n), -0.5, 1.5]); grid on;
xlabel('n', 'vertical', 'bottom'); ylabel('Amplitude');
title('Impulse Response', 'fontsize', TF); subplot(2, 2, 3);
plot(w/pi, Hr, 'm', 'linewidth', 1.0); axis([0, 1, -1, 6]); grid on;
xlabel('frequency in \pi units', 'fontsize', 10); ylabel('Amplitude');
title(' Amplitude Response ', 'fontsize', TF);
set(gca, 'xtick', [0, wp/pi, ws/pi, 1]);
set(gca, 'ytick', [0, I]); subplot(2, 2, 2);
plot(w/pi, Hdb, 'm', 'linewidth', 1.0); axis([0, 1, -50, 10]); grid on;
xlabel('frequency in \pi units '); ylabel('Decibels');
title('Log-mag Response ', 'fontsize', TF);
set(gca, 'xtick', [0, wp/pi, ws/pi, 1]);
set(gca, 'ytick', [-50, round(min_attn), 0]); subplot(2, 2, 4);
lw = length(w)-1; PB = [0:floor(wp/pi*lw)]; HrPB = Hr(PB+1)-I;
SB = [ceil(ws/pi*lw):lw]; HrSB = Hr(SB+1);
[AX, H1, H2] = plotyy(PB/lw, HrPB, SB/lw, HrSB); delta1 = round(delta1*I*100)/100; delta2 = round(delta2*I*100)/100;
set(AX(1), 'xtick', [0, wp/pi, ws/pi, 1]);
set(AX(1), 'ytick', [-delta1, 0, delta1], 'Ycolor', 'g');
set(AX(2), 'xtick', [0, wp/pi, ws/pi, 1]);
set(AX(2), 'ytick', [-delta2, 0, delta2], 'Ycolor', 'r');
set(H1, 'color', 'g', 'linewidth', 1);
set(H2, 'color', 'r', 'linewidth', 1);
title('scaled ripples', 'fontsize', TF);
xlabel('Frequency in \pi units');

  运行结果:

尽管该滤波器通过了原始信号,如果信号是全频带π弧度的,那么邻近的谱能量可能发生泄漏。因此需要更好的设计指标,本节的后面有讨论。

《DSP using MATLAB》示例 Example 9.8的更多相关文章

  1. 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 ...

  2. DSP using MATLAB 示例 Example3.19

    代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Discrete-time Signa ...

  3. DSP using MATLAB示例Example3.18

    代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Continuous-time Fou ...

  4. 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 ...

  5. 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 ...

  6. DSP using MATLAB 示例Example3.17

  7. 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, ...

  8. 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 ...

  9. DSP using MATLAB 示例 Example3.13

    上代码: w = [0:1:500]*pi/500; % freqency between 0 and +pi, [0,pi] axis divided into 501 points. H = ex ...

  10. DSP using MATLAB 示例 Example3.12

    用到的性质 代码: n = -5:10; x = sin(pi*n/2); k = -100:100; w = (pi/100)*k; % freqency between -pi and +pi , ...

随机推荐

  1. 使用Github发布自己的网站

    1.编写好自己的index.html 2.在github上新建一个分支,分支名需要按xxx.github.com(xxx为github账号名): 3.进入分支的setting界面,自动生成网页,会在分 ...

  2. 关于eval 与new Function 到底该选哪个?

    废话不多说,直接上测试代码 复制代码 代码如下: var aa = "{name:'cola',item:[{age:11},{age:22},{age:23},{age:23}]}&quo ...

  3. Gulp命令自动生成精灵图

    文件目录说明 gulpfile.js代码 var gulp = require('gulp'); var spritesmith = require('gulp.spritesmith'); var ...

  4. linux各版本基线检查脚本(centos6、centos7、ubuntu系列)

    以下是centos7基线检查脚本: #!/bin/bash #version v1. by pensar #操作系统linux 配置规范--centos7 cat <<EOF ****** ...

  5. 在apache中使用.htaccess文件的注意事项

    在apache的配置文件中: <VirtualHost *:80> ServerName tp5.com DocumentRoot d:/wamp/www/tp5.com/public & ...

  6. Dekker算法在多核处理器下的失效

    Dekker algorithm是一种著名的并发编程的算法,Dekker算法的核心部分是一组对称的代码来访问一组共享变量,使得两个线程不可能同时进入临界区(只要cpu内存模型是遵循顺序一致性的),从而 ...

  7. SSH Secure File Transfer Client连接远程设备报“algorithm negotiation failed”错的解决方法

    SSH Secure File Transfer Client连接远程设备报"algorithm negotiation failed"错的解决方法 ssh client 报 al ...

  8. 【安装】ES的安装过程

    1.安装ES 首先我们需要去官网下载安装包  官方下载地址 下载后不需要编译,直接解压 解压后结构是这样的(2.5以上版本会有plugins目录,没有的需要手动创建) 方式一: 创建一个es用户(因为 ...

  9. (译)综合指南:通过Ubuntu 16.04上从Source构建来安装支持GPU的Caffe2

    (译)综合指南:通过Ubuntu 16.04上从Source构建来安装支持GPU的Caffe2 译者注: 原文来自:https://tech.amikelive.com/node-706/compre ...

  10. lua if 流程控制

    Lua认为false和nil为假,true和非nil为真. 要注意的是Lua中 0 为 true --[ 为 true ] ) then print("0 为 true") end ...