代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Exameple 9.16 \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);
%% ------------------------------------------------------------------------ % Given Parameters:
I = 4; D = 3; Rp = 0.1; As = 40;
wxp = 0.8*pi; wxs1 = 0.9*pi; wxs2 = 0.7*pi; % Computed Filter Parameters
wp = wxp/I; ws = min((2*pi/I-wxs1/I), (2*pi/D-wxs2/I)); % Filter Design:
[delta1, delta2] = db2delta(Rp, As); [N, F, A, weights] = firpmord([wp, ws]/pi, [1, 0], [delta1, delta2], 2);
N = ceil(N/2)*2 + 1;
N
F
A
weights h = firpm(N, F, I*A, weights);
%delay = N/2; % delay imparted by the filter
% n = [0:length(h)-1];
[Hr, w, a, L] = Ampl_res(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.16');
set(gcf,'Color','white'); TF = 10; subplot(2, 1, 1);
plot(w/pi, Hr, 'm', 'linewidth', 1.0); axis([0, 1, -0.1, I+0.4]); grid on;
xlabel('Frequency in \pi units', 'vertical', 'middle'); ylabel('Amplitude', 'vertical', 'middle');
title('Amplitude Response ', 'fontsize', TF, 'vertical', 'baseline');
set(gca, 'xtick', [0, wp/pi, ws/pi, 1]);
set(gca, 'ytick', [0, I]); subplot(2, 1, 2);
plot(w/pi, Hdb, 'm', 'linewidth', 1.0); axis([0, 1, -60, 10]); grid on;
xlabel('Frequency in \pi units', 'fontsize', TF, 'vertical', 'middle');
ylabel('Decibels', 'vertical', 'cap');
title('Log-magnitude Response', 'fontsize', TF, 'vertical', 'baseline');
set(gca, 'xtick', [0, wp/pi, ws/pi, 1], 'ytick', [-60, round(min_attn), 0]);

  运行结果:

衰减达到40dB。

---------------------------------------------------------------------------

第9章结束。

---------------------------------------------------------------------------

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

  1. 《DSP using MATLAB》Problem 7.16

    使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  2. 《DSP using MATLAB》Problem 4.16

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  3. 《DSP using MATLAB》Problem 2.16

    先由脉冲响应序列h(n)得到差分方程系数,过程如下: 代码: %% ------------------------------------------------------------------ ...

  4. DSP using MATLAB》Problem 8.16

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

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

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

  7. DSP using MATLAB 示例 Example3.19

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

  8. DSP using MATLAB示例Example3.18

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

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

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

随机推荐

  1. esLint参数设置

    package.json { "name": "testEsLint", "version": "1.0.0", &qu ...

  2. 人脸识别技术大总结(1):Face Detection & Alignment

    http://blog.jobbole.com/85783/     首页 最新文章 IT 职场 前端 后端 移动端 数据库 运维 其他技术 - 导航条 - 首页 最新文章 IT 职场 前端 - Ja ...

  3. TED #07# How to inspire every child to be a lifelong reader

    Alvin Irby: How to inspire every child to be a lifelong reader Prepare elementarykitchen tableforced ...

  4. Python笔记 #06# NumPy Basis & Subsetting NumPy Arrays

    原始的 Python list 虽然很好用,但是不具备能够“整体”进行数学运算的性质,并且速度也不够快(按照视频上的说法),而 Numpy.array 恰好可以弥补这些缺陷. 初步应用就是“整体数学运 ...

  5. UVA10529 Dumb Bones

    UVA10529 Dumb Bones go to solution 设$f[i]$表示叠$i$个的骨牌的期望 $O(n)$做法 #include<iostream> #include&l ...

  6. 20155201 2016-2017-2 《Java程序设计》第十周学习总结

    20155201 2016-2017-2 <Java程序设计>第十周学习总结 教材学习内容总结 Java密码技术 安全的三个属性 机密性 完整性 可用性 密码学: 主要是研究保密通信和信息 ...

  7. 关于LIS和LCS问题的o(nlogn)解法

    o(n^2)解法就不赘述了,直接解释o(nlogn)解法 LIS最长递增子序列: 先明确一个结论:在长度最大为len的递增序列里若末尾元素越小,该递增序列越容易和后面的子序列构造出一个更长的递增子序列 ...

  8. Python学习札记(三十五) 面向对象编程 Object Oriented Program 6

    参考:实例属性和类属性 NOTE Python是动态语言,根据类创建的实例可以任意绑定属性. class Student(object): def __init__(self, name): self ...

  9. 10_MySQL DQL_子查询(嵌套的select)

    #子查询/* 含义:出现在其他语句中的select语句,称为子查询(内查询)           内部嵌套其他select语句的查询,称为主查询(外查询) 特点: 1.子查询都会放在小括号内 2.单行 ...

  10. 51Nod 1503 猪和回文

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1503 思路: 没想到要用DP去解决. 题目是从起点出发走,我们可以从起点 ...