代码:

%% ------------------------------------------------------------------------
%% 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. git拉取GitLab工程报错Repository not found

    # git clone http://xxx/jiqing/frog.git 正克隆到 'frog'... fatal: repository 'http://xxx/jiqing/frog.git/ ...

  2. python列表解析进阶

    如果要获得一个(元素为整数的)列表里面的偶数,很容易想到列表解析: [i for i in nums if i%2==0] 但是如果要使列表的长度不变,让奇数用0来填充,可能你会直接写: [i for ...

  3. C#忽略decimal多余的0

    decimal test=1.2000:test.ToString("0.####");

  4. Oracle归档的开启和关闭

    --1.开启归档 [步骤] a.一致性关闭数据库(shutdown [immediate | transactional |normal]) b.启动到mount阶段(startup mount) c ...

  5. http协议与soap协议区别

  6. 【Demo】jQuery 可编辑表格

    功能实现: (1)设定单元格的单击事件,判定被单击单元格是否已经是可编辑状态: (2)取出单元格原有内容,想单元格中加入文本框,并把原有内容显示在文本框中: (3)当用户编辑完成或者取消编辑后,将文本 ...

  7. AOP(面向切面)的粗俗理解

    百度百科的解释:AOP主要实现的目的是针对业务处理过程中的切面进行提取,它所面对的是处理过程中的某个步骤或阶段,以获得逻辑过程中各部分之间低耦合性的隔离效果. 一个比较绕的概念,简单来说就是把不影响业 ...

  8. IOS-如何锁定Xcode的API头文件

    如何锁定Xcode的API头文件1, 打开终端2, 前往Xcode.app, 命令: cd /Applications/Xcode.app3, 把头文件修改为只读, 命令: sudo chown -h ...

  9. 那如何判断页面是在移动端还是PC端打开的

    网上有很多方法,写的或难或简单,实际上一行代码就够了. window.location.href = /Android|webOS|iPhone|iPod|BlackBerry/i.test(navi ...

  10. 【转】OpenWRT开发自定义应用方法

    [转]OpenWRT开发自定义应用方法 转自:http://blog.csdn.net/rudyn/article/details/38616783 OpenWRT编译成功完成后,所有的产品都会放在编 ...