《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 ...
随机推荐
- RabittMQ实践(二): RabbitMQ 与spring、springmvc框架集成
一.RabbitMQ简介 1.1.rabbitMQ的优点(适用范围)1. 基于erlang语言开发具有高可用高并发的优点,适合集群服务器.2. 健壮.稳定.易用.跨平台.支持多种语言.文档齐全.3. ...
- VS2010/MFC编程入门之十三(对话框:属性页对话框及相关类的介绍)
前面讲了模态对话框和非模态对话框,本节开始鸡啄米讲一种特殊的对话框--属性页对话框.另外,本套教程所讲大部分对VC++各个版本均可适用或者稍作修改即可,但考虑到终究还是基于VS2010版本的,所以将& ...
- uva672
Gangsters N gangsters are going to a restaurant. The i-th gangster comes at the time Ti and has t ...
- Python 自带IDLE 如何打开
- P1757 通天之分组背包 / hdu1712 ACboy needs your help (分组背包入门)
P1757 通天之分组背包 hdu1712 ACboy needs your help hdu1712题意:A[i][j]表示用j天学习第i个课程能够得到A[i][j]的收益,求m天内获得的收益最大值 ...
- 使用NodeJS将文件或图像上传到服务器
原文链接:http://www.codeceo.com/article/nodejs-upload-file-to-server.html
- 在pom.xml中使用distributionManagement将项目打包上传到nexus私服
本文介绍 如何在pom.xml中使用distributionManagement将项目打包上传到nexus私服 1.pom.xml文件添加distributionManagement节点 <!- ...
- Linux硬盘扩容(非LVM)
环境说明: 虚拟机:Centos6 [root@elements ~]# cat /etc/redhat-release CentOS release 6.10 (Final) [root@eleme ...
- UVa 11419 我是SAM(最小点覆盖+路径输出)
https://vjudge.net/problem/UVA-11419 题意:一个网格里面有一些目标,可以从某一行,某一列发射一发子弹,可以打掉它:求最少的子弹,和在哪里打? 思路: 每个点的x坐标 ...
- Thinking in java note1
Part information collecting from http://blog.csdn.net/leonliu06/article/details/78638841 1. 如果已经定义了一 ...