代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Exameple 9.4 \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);
%% ------------------------------------------------------------------------ n = 0:256; k1 = 64; k2 = k1+32; m = 0:(k2-k1); %% -----------------------------------------------------------------
%% Plot
%% -----------------------------------------------------------------
Hf1 = figure('units', 'inches', 'position', [1, 1, 8, 6], ...
'paperunits', 'inches', 'paperposition', [0, 0, 6, 4], ...
'NumberTitle', 'off', 'Name', 'Exameple 9.4');
set(gcf,'Color','white'); TF = 10;
% (a) Original signal
x = cos(pi*n); subplot(2, 2, 1);
Ha = stem(m, x(m+k1+1), 'g', 'filled'); axis([-1, 33, -1.1, 1.1]); grid on;
set(Ha, 'markersize', 2); xlabel('n'); ylabel('Amplitude');
title('Original Sequence x(n)', 'fontsize', TF);
set(gca, 'xtick', [0, 16, 32]);
set(gca, 'ytick', [-1, 0, 1]); % (b) Interpolation by D = 2
I = 2; y = interp(x, I); subplot(2, 2, 2);
Hb = stem(m, y(m+k1*I+1), 'c', 'filled'); axis([-1, 33, -1.1, 1.1]); grid on;
set(Hb, 'markersize', 2); xlabel('n'); ylabel('Amplitude');
title('Interpolated by I = 2', 'fontsize', TF);
set(gca, 'xtick', [0, 16, 32]);
set(gca, 'ytick', [-1, 0, 1]); % (c) Interpolation by I = 4
I = 4; y = interp(x, I); subplot(2, 2, 3);
Hc = stem(m, y(m+k1*I+1), 'r', 'filled'); axis([-1, 33, -1.1, 1.1]); grid on;
set(Hc, 'markersize', 2); xlabel('n'); ylabel('Amplitude');
title('Interpolated by I = 4', 'fontsize', TF);
set(gca, 'xtick', [0, 16, 32]);
set(gca, 'ytick', [-1, 0, 1]); % (d) Interpolation by I = 8
I = 8; y = interp(x, I); subplot(2, 2, 4);
Hd = stem(m, y(m+k1*I+1), 'm', 'filled'); axis([-1, 33, -1.1, 1.1]); grid on;
set(Hd, 'markersize', 2); xlabel('n'); ylabel('Amplitude');
title('Interpolated by I = 8', 'fontsize', TF);
set(gca, 'xtick', [0, 16, 32]);
set(gca, 'ytick', [-1, 0, 1]);

  运行结果:

从图看,I的所有三个数值下的插值序列是合适的,在更高的采样率上展示了原始正弦信号x(n)。I=8的例子里,

插值序列从形状上看不像是精确的正弦信号。这可能是由于低通滤波器和理想低通滤波器有差距而造成的。

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

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

  2. DSP using MATLAB 示例 Example3.19

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

  3. DSP using MATLAB示例Example3.18

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

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

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

  6. DSP using MATLAB 示例Example3.17

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

  8. DSP using MATLAB 示例 Example3.15

    上代码: subplot(1,1,1); b = 1; a = [1, -0.8]; n = [0:100]; x = cos(0.05*pi*n); y = filter(b,a,x); figur ...

  9. DSP using MATLAB 示例 Example3.13

    上代码: w = [0:1:500]*pi/500; % freqency between 0 and +pi, [0,pi] axis divided into 501 points. H = ex ...

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

随机推荐

  1. 【转】Java运行时数据区简介及堆与栈的区别

    理解JVM运行时的数据区是Java编程中的进阶部分.我们在开发中都遇到过一个很头疼的问题就是OutOfMemoryError(内存溢出错误),但是如果我们了解JVM的内部实现和其运行时的数据区的工作机 ...

  2. setTimout执行时间

    在浏览器中,JavaScript引擎是单线程执行的.也就是说,在同一时间内,只能有一段代码被JavaScript引擎执行.页面加载时,JavaScript引擎会顺序执行页面上所有JavaScript代 ...

  3. Sql字符串操作函数

    1.去空格函数 (1).LTRIM() 把字符串头部的空格去掉. (2).RTRIM() 把字符串尾部的空格去掉. 2.字符转换函数(1).ASCII()返回字符表达式最左端字符的ASCII 码值.在 ...

  4. unity屏幕坐标转世界坐标结果为(0,0,0)

    代码: wv转出来一直为(0,0,0),卡了好久,问别人说要转化的屏幕坐标Z不能为0 阿西吧!特此记录

  5. bootstrap 知识点

    1.datetimepicker //带分钟选择 $('.form_datetime').datetimepicker({ format: 'yyyy-mm-dd HH:mm:ss', languag ...

  6. UVA-10047 The Monocycle (图的BFS遍历)

    题目大意:一张图,问从起点到终点的最短时间是多少.方向转动也消耗时间. 题目分析:图的广度优先遍历... 代码如下: # include<iostream> # include<cs ...

  7. 【转】ubuntu下如何将笔记本自带的键盘关闭

    想必大家都经历过这样的情况:在使用usb接口的外接键盘的时候,很容易按到笔记本自带的键盘,从而导致输入错误.尤其是你将外接键盘放在笔记本键盘上面的时候.怎么解决这个问题呢? 搜索之后,找到了答案.注意 ...

  8. 杀死dialog

    先 pkill -9 normal.sh 和  pkill -9 terminal_ui.sh 然后在pkill -9 dialog

  9. 重置input checked

    <!-- 作者:duke 时间:2018-10-24 描述: 重置input 样式--> <!DOCTYPE HTML><html> <head> &l ...

  10. JS中apply与call的用法

    JavaScript中有一个call和apply方法,其作用基本相同,但也有略微的区别. 先来看看JS手册中对call的解释: call 方法调用一个对象的一个方法,以另一个对象替换当前对象. cal ...