代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Exameple 9.11 \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);
%% ------------------------------------------------------------------------ % Filter Design:
D = 2; Rp = 0.1; As = 30; wp = pi/D; ws = wp+0.1*pi;
[delta1, delta2] = db2delta(Rp, As);
%weights = [delta2/delta1, 1];
[N, F, A, weights] = firpmord([wp, ws]/pi, [1, 0], [delta1, delta2], 2);
h = firpm(N, 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
%% ----------------------------------------------------------------- % Input signal
Hf1 = figure('units', 'inches', 'position', [1, 1, 8, 6], ...
'paperunits', 'inches', 'paperposition', [0, 0, 6, 4], ...
'NumberTitle', 'off', 'Name', 'Exameple 9.11');
set(gcf,'Color','white'); TF = 10; subplot(2, 2, 1);
Hs1 = stem(n, h, 'filled'); set(Hs1, 'markersize', 2, 'color', 'g');
axis([-1, length(n), -0.15, 0.6]); grid on;
xlabel('n', 'vertical', 'bottom'); ylabel('Amplitude', 'vertical', 'cap');
title('Inpulse Response ', 'fontsize', TF, 'vertical', 'baseline');
set(gca, 'xtick', [n(1), n(end)]);
set(gca, 'ytick', [0, 0.5]); subplot(2, 2, 3);
plot(w/pi, Hr, 'm', 'linewidth', 1.0); axis([0, 1, -0.1, 1.1]); grid on;
xlabel('Frequency in \pi units', 'vertical', 'middle'); ylabel('Amplitude', 'vertical', 'cap');
title('Amplitude Response', 'fontsize', TF, 'vertical', 'baseline');
set(gca, 'xtick', [0, wp/pi, ws/pi, 1]);
set(gca, 'ytick', [0, 1]); subplot(2, 2, 2);
plot(w/pi, Hdb, 'm', 'linewidth', 1.0); axis([0, 1, -50, 10]); grid on;
xlabel('Frequency in \pi units', 'vertical', 'middle'); ylabel('Decibels', 'vertical', 'cap');
title('Log-magnitude Response ', 'fontsize', TF, 'vertical', 'baseline');
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)-1;
SB = [ceil(ws/pi*lw):lw]; HrSB = Hr(SB+1);
[AX, H1, H2] = plotyy(PB/lw, HrPB, SB/lw, HrSB);
delta1 = round(delta1*1000)/1000; delta2 = round(delta2*100)/100;
set(AX(1), 'xtick', [0, wp/pi, ws/pi, 1], 'ytick', [-delta1, 0, delta1], 'Ycolor', 'g');
set(AX(2), 'xtick', [0, wp/pi, ws/pi, 1], 'ytick', [-delta2, 0, delta2], 'Ycolor', 'r'); set(H1, 'color', 'g', 'linewidth', 1);
set(H2, 'color', 'r', 'linewidth', 1);
title('Unweighted Ripples', 'fontsize', TF, 'vertical', 'baseline'); xlabel('Frequency in \pi units', 'vertical', 'middle'); ylabel('Amplitude', 'vertical', 'cap');

  运行结果:

滤波器在通带[0,π/2]上无畸变通过信号。但是,因为过渡带较宽,所以过渡带中的信号有可能假频混入到感兴趣的频带
中。30dB的衰减可能使得在减采样过程后阻带的部分谱折叠到通带中。因此,我们需要一个更好的方法。

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

  1. 《DSP using MATLAB》Problem 7.11

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  2. 《DSP using MATLAB》Problem 6.11

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  3. 《DSP using MATLAB》Problem 5.11

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  4. 《DSP using MATLAB》Problem 4.11

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

  5. 《DSP using MATLAB》Problem 8.11

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

  6. DSP using MATLAB 示例 Example3.11

    用到的性质 上代码: n = -5:10; x = rand(1,length(n)); k = -100:100; w = (pi/100)*k; % freqency between -pi an ...

  7. DSP using MATLAB 示例Example2.11

    上代码: b = [1]; a = [1, -1, 0.9]; n = [-20:120]; h = impz(b,a,n); set(gcf,'Color','white'); %subplot(2 ...

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

  9. DSP using MATLAB 示例 Example3.19

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

  10. DSP using MATLAB示例Example3.18

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

随机推荐

  1. tp模板基础

    目录简介 创建应用 在项目目录创建入口文件shop/index.php 创建虚拟主机,访问应 路由形式 路由: 系统从URL参数中分析出当前请求的分组.控制器.和操作的过程就是“路由”. Tp框架路由 ...

  2. Keras实践:模型可视化

    Keras实践:模型可视化 安装Graphviz 官方网址为:http://www.graphviz.org/.我使用的是mac系统,所以我分享一下我使用时遇到的坑. Mac安装时在终端中执行: br ...

  3. Restoring Numbers

                                                                                  D. Restoring Numbers   ...

  4. PHP保存Base64图片base64_decode的问题 文件打不开的问题

      PHP对Base64的支持非常好,有内置的base64_encode与base64_decode负责图片的Base64编码与解码. 编码上,只要将图片流读取到,而后使用base64_encode进 ...

  5. aTool在线工具

    在线HTTP POST/GET接口测试工具 - aTool在线工具 地址:http://www.atool.org/httptest.php在线接口测试工具接口测试是测试系统组件间接口的一种测试.接口 ...

  6. Web开发相关笔记 #03#

    HTTP Status 500  ※  jsp 放在 WEB-INF 外面  ※ 使用 JDBC 时需要 close 什么 ※ execute 和 executeUpdate ※ How can I ...

  7. Python 3 并发编程多进程之进程池与回调函数

    Python 3 进程池与回调函数 一.进程池 在利用Python进行系统管理的时候,特别是同时操作多个文件目录,或者远程控制多台主机,并行操作可以节约大量的时间.多进程是实现并发的手段之一,需要注意 ...

  8. ZLYD团队第三周项目总结

    ZLYD团队第三周项目总结 项目进展 我们的吃豆子游戏的程序由八个文件组成:Wall.java.Gold.java.Player.java.Fruit.java.Enemy.java.Ticker.j ...

  9. 使用JavaScript下载csv文件

    前端可以使用JavaScript在客户端下载包含页面数据的文件,这里以下载CSV格式文件为例,代码如下: function downloadData(data, filename, type) { v ...

  10. vSphere Client开启虚拟机提示:出现了常规系统错误: 由于目标计算机积极拒绝,无法连接。

    进入VCenter Server服务器上 进入服务管理器,查看 VMware vCenter workflow manager 是否启动,如未启动,则改为启动,问题得以解决 再次启动虚拟机,已启动!