《DSP using MATLAB》 示例 Example 9.12

代码:
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Exameple 9.12 \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 = 30; wp = pi/D; ws = wp+0.1*pi; % Filter Design:
[delta1, delta2] = db2delta(Rp, As); [N, F, A, weights] = firpmord([wp, ws]/pi, [1, 0], [delta1, delta2], 2);
h = firpm(N, F, A, weights);
delay = N/2; % delay imparted by the filter %% -----------------------------------------------------------------
%% Plot
%% ----------------------------------------------------------------- % Input signal x1(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.12');
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');
title('Input Singal: x1(n) = cos(\pin/8) ', 'fontsize', TF, 'vertical', 'baseline');
set(gca, 'xtick', [0:8:32]);
set(gca, 'ytick', [-1, 0, 1]); % Decimation of x1(n): D = 2
y = upfirdn(x, h, 1, D);
m = delay+1:1:128/D+delay+1; y = y(m); m = 0:16; y = y(16:32); subplot(2, 2, 3);
Hs2 = stem(m, y, 'filled'); set(Hs2, 'markersize', 2, 'color', 'm');
axis([-1, 17, -1.2, 1.2]); grid on;
xlabel('m', 'vertical', 'middle'); ylabel('Amplitude', 'vertical', 'cap');
title('Output Singal: y1(n): D=2', 'fontsize', TF, 'vertical', 'baseline');
set(gca, 'xtick', [0:8:32]/D);
set(gca, 'ytick', [-1, 0, 1]); % Input signal x2(n) = cos(8*pi*n/16)
n = [0:256]; x = cos(8*pi*n/(16));
n2 = n(1:33); x2 = x(33:65); % for plotting purposes subplot(2, 2, 2);
Hs3 = stem(n2, x2, 'filled'); set(Hs3, 'markersize', 2, 'color', 'g');
axis([-2, 34, -1.2, 1.2]); grid on;
xlabel('n', 'vertical', 'middle'); ylabel('Amplitude', 'vertical', 'cap');
title('Input Singal: x2(n)=cos(\pin/2) ', 'fontsize', TF, 'vertical', 'baseline');
set(gca, 'xtick', [0:8:32]);
set(gca, 'ytick', [-1, 0, 1]); % Decimation of x2(n): D = 2
y = upfirdn(x, [h], 1, D); % y = downsample(conv(x,h),2);
m = delay+1:1:128/D+delay+1; y = y(m); m = 0:16; y = y(16:32); subplot(2, 2, 4);
Hs4 = stem(m, y, 'filled'); set(Hs4, 'markersize', 2, 'color', 'm');
axis([-1, 17, -1.2, 1.2]); grid on;
xlabel('m', 'vertical', 'middle'); ylabel('Amplitude', 'vertical', 'cap');
title('Output Singal: y2(n): D=2', 'fontsize', TF, 'vertical', 'baseline');
set(gca, 'xtick', [0:8:32]/D);
set(gca, 'ytick', [-1, 0, 1]);
运行结果:

左半边的图展示了x1(n)和相应减采样结果信号y1(n),右半边展示了x2(n)和相应减采样y2(n)。两种情况下减采样
看上去都正确。如果我们选π/2以上的任何频率,那么滤波器将会衰减或消除信号。
《DSP using MATLAB》 示例 Example 9.12的更多相关文章
- 《DSP using MATLAB》Problem 7.12
阻带衰减50dB,我们选Hamming窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 6.12
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 5.12
1.从别的地方找的证明过程: 2.代码 function x2 = circfold(x1, N) %% Circular folding using DFT %% ----------------- ...
- 《DSP using MATLAB》Problem 8.12
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 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 , ...
- DSP using MATLAB 示例Example2.12
代码: b = [1]; a = [1, -0.9]; n = [-5:50]; h = impz(b,a,n); set(gcf,'Color','white'); %subplot(2,1,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 ...
- 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.11
用到的性质 上代码: n = -5:10; x = rand(1,length(n)); k = -100:100; w = (pi/100)*k; % freqency between -pi an ...
随机推荐
- (6)Cocos2d-x 3.0坐标系详解
Cocos2d-x坐标系和OpenGL坐标系相同,都是起源于笛卡尔坐标系. 笛卡尔坐标系 笛卡尔坐标系中定义右手系原点在左下角,x向右,y向上,z向外,OpenGL坐标系为笛卡尔右手系. 屏幕坐标系和 ...
- hdu1700 Points on Cycle
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=1700 题目: Points on Cycle Time Limit: 1000/1000 MS ...
- Android ActionBar自定义
关于自定义的ActionBar的实现过程,这里做下笔记以供之后查看. 1.默认状态 使用Android Studio新建一个名为“ActionBar”的应用,默认actionbar如图(1)所示. 图 ...
- iOS error: -34018
一般报这个错误是由于操作keychain 报的错. 遇到该情况的情况: 1.是否打开权限 2.苹果自身的bug,传送门:https://stackoverflow.com/questions/2974 ...
- Qml应用程序的性能考虑与建议
本文翻译自Qt官网文档: http://doc.qt.io/qt-5/qtquick-performance.html QtQml应用程序的性能考虑与建议 1.时间考虑 作为一名程序开发者,应该努力使 ...
- Jedis连接池
jedis是官方首选的java客户端开发包 Redis不仅是使用命令来操作,现在基本上主流的语言都有客户端支持,比如java.C.C#.C++.php.Node.js.Go等. 在官方网站里列一些Ja ...
- Python笔记 #05# Package & pip3
datacamp + 日常收集 How to install Package pip3 & What is difference between pip and pip3? Import P ...
- 初识PHP(一)基础语法
一直准备学习PHP,结果前一段时间总是有事情,耽误了一阵子.现在赶快迎头赶上! 这个系列只是谈谈我对于PHP的一些看法,不是教程性质的.另外我是小白,只是写写随笔,大神求轻拍.本人学习过c .java ...
- Python3基础 print(,end=) 输出内容的末尾加入空格
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- ISSCC 2017论文导读 Session 14: A 28nm SoC with a 1.2GHz Prediction Sparse Deep-Neural-Network Engine
A 28nm SoC with a 1.2GHz 568nJ/Prediction Sparse Deep-Neural-Network Engine with >0.1 Timing Erro ...