代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Exameple 9.14 \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: D = 2; Rp = 0.1; As = 50; wxp = pi/8; wxs = pi/D; wp = wxp; ws = (2*pi/D)-wxs; % 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;
h = firpm(N, F, A, weights);
delay = N/2; % delay imparted by the filter %% -----------------------------------------------------------------
%% Plot
%% ----------------------------------------------------------------- % Input signal x(n) = cos(2*pi*n/16)
n = [0:256]; x = cos(pi*n/8);
n1 = n(1:33); x1 = x(33:65); % for plotting purposes Hf1 = figure('units', 'inches', 'position', [1, 1, 8, 6], ...
'paperunits', 'inches', 'paperposition', [0, 0, 6, 4], ...
'NumberTitle', 'off', 'Name', 'Exameple 9.14');
set(gcf,'Color','white'); TF = 10; subplot(2, 2, 1);
Hs1 = stem(n1, x1, 'filled'); set(Hs1, 'markersize', 2, 'color', 'g');
axis([-2, 34, -1.2, 1.2]); grid on;
xlabel('n', 'vertical', 'middle'); ylabel('Amplitude', 'vertical', 'middle');
title('Input Singal: x(n) = cos(\pin/8) ', 'fontsize', TF, 'vertical', 'baseline');
set(gca, 'xtick', [0:8:32]);
set(gca, 'ytick', [-1, 0, 1]); % Decimation of x(n): D = 2
y = upfirdn(x, h, 1, D);
m = delay+1:1:128/D+delay+1; y1 = y(m); m = 0:16; y1 = y1(14:30); subplot(2, 2, 3);
Hs2 = stem(m, y1, 'filled'); set(Hs2, 'markersize', 2, 'color', 'm');
axis([-1, 17, -1.2, 1.2]); grid on;
xlabel('m', 'vertical', 'middle'); ylabel('Amplitude', 'vertical', 'middle');
title('Output Singal: y(n): D=2', 'fontsize', TF, 'vertical', 'baseline');
set(gca, 'xtickmode', 'manual', 'xtick', [0:8:32]/D);
set(gca, 'ytickmode', 'manual', 'ytick', [-1, 0, 1]); % Filter Design Plots
[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);
subplot(2, 2, 2);
plot(w/pi, Hr, 'm', 'linewidth', 1.0); axis([0, 1, -0.1, 1.1]); grid on;
xlabel('Frequency in \pi units', 'fontsize', TF, 'vertical', 'middle');
ylabel('Amplitude', 'vertical', 'cap');
title('Amplitude Response', 'fontsize', TF, 'vertical', 'baseline');
set(gca, 'xtick', [0, wp/pi, ws/pi, 1], 'ytick', [0, 1]); subplot(2, 2, 4);
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]);

  运行结果:

设计的滤波器达到51dB的衰减,并且减采样的信号是正确的。

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

  1. 《DSP using MATLAB》Problem 7.14

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

  2. 《DSP using MATLAB》Problem 6.14

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

  3. 《DSP using MATLAB》Problem 5.14

    说明:这两个小题的数学证明过程都不会,欢迎博友赐教. 直接上代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  4. 《DSP using MATLAB》Problem 4.14

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

  5. 《DSP using MATLAB》Problem 2.14

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

  6. 《DSP using MATLAB》Problem 8.14

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

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

  8. DSP using MATLAB 示例 Example3.19

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

  9. DSP using MATLAB示例Example3.18

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

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

随机推荐

  1. Excel error 64-bit version of SSIS

    问题是 在windows server 2008 64位的计划任务执行 ssis 的错误 ,ssis你们带有读取excel 日期 2015/3/17 11:50:34日志 作业历史记录 (SSIS_U ...

  2. java之进程和线程

    1.进程和线程的通俗例子. 2.进程和线程关系.

  3. python webdriver grid多节点运行webdriver程序

    grid整理: 机制 Hub机器和节点机器上要装jdk和jar包 A机器:hub  中控:用来监控所有节点机的状态 启动命令: java -jar selenium-server-standalone ...

  4. GPS数据解析

    1.摘要 GPS模块使用串口通信,那么它的的数据处理本质上还是串口通信处理,只是GPS模块的输出的有其特定的格式,需要字符串处理逻辑来解析其含义.如何高效的处理从GPS模块接收到的数据帧,是GPS驱动 ...

  5. 0510进程 multiprocess模块

    process模块是一个创建进程的模块,借助这个模块,就可以完成进程的创建. 创建模块 import os import time from multiprocessing import Proces ...

  6. pyimage search研究

    包括<软实力>的作者,类似 http://www.learnopencv.com/, 这次调查研究的 http://www.pyimagesearch.com 是一个独立的博客,作者是机器 ...

  7. 20172305 2018-2019-1 《Java软件结构与数据结构》第二周学习总结

    20172305 2018-2019-1 <Java软件结构与数据结构>第二周学习总结 教材学习内容总结 本周内容主要为书第三章和第四章的内容: 第三章(以数组来替代栈的作用) 集合(聚集 ...

  8. openwrt编译系统制作ubi镜像时会使用系统自带的ubinize还是openwrt编译系统中编译的ubinize

    答:使用openwrt编译系统中编译的ubinize,那么这个工具在哪个目录下?在staging_dir/host/bin目录下

  9. ubuntu18.04 install pip

    1. environment release version: bionic kernel version:4.15.0-29-generic 2.install pip 2.1 sudo apt-g ...

  10. The current .NET SDK does not support targeting .NET Core 3.0

    编译错误 Severity Code Description Project File Line Suppression StateError NETSDK1045 The current .NET ...