代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Exameple 9.6 \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:2048; k1 = 256; 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.6');
set(gcf,'Color','white'); TF = 10;
% (a) Original singal
x = cos(0.125*pi*n);
subplot(2, 2, 1);
Ha = stem(m, x(m+k1+1), 'filled'); axis([-1, 33, -1.1, 1.1]); grid on;
set(Ha, 'markersize', 2); xlabel('n'); ylabel('Amplitude');
title('Original Signal x(n)', 'fontsize', TF);
set(gca, 'xtick', [0, 16, 32]);
set(gca, 'ytick', [-1, 0, 1]); % (b) Sample rate conversion by 3/2: I = 3, D = 2
I = 3; D = 2; [y, h] = resample(x, I, D);
fprintf('\n The Length of filter is %d , and length of y is %d \n', length(h), length(y) ); subplot(2, 2, 2);
Hb = stem(m, y(m+k1*I/D+1), 'filled'); axis([-1, 33, -1.1, 1.1]); grid on;
set(Hb, 'markersize', 2); xlabel('n'); ylabel('Amplitude');
title('Sample rate I/D: I = 3, D = 2 ', 'fontsize', TF);
set(gca, 'xtick', [0, 16, 24, 32]);
set(gca, 'ytick', [-1, 0, 1]); % (c) Sample rate conversion by 3/4: I = 3, D = 4
I = 3; D = 4; [y, h] = resample(x, I, D);
fprintf('\n The Length of filter is %d , and length of y is %d \n', length(h), length(y) ); subplot(2, 2, 3);
Hc = stem(m, y(m+k1*I/D+1), 'filled'); axis([-1, 33, -1.1, 1.1]); grid on;
set(Hc, 'markersize', 2); xlabel('n'); ylabel('Amplitude');
title('Sample rate I/D: I = 3, D = 4 ', 'fontsize', TF);
set(gca, 'xtick', [0, 12, 16, 32]);
set(gca, 'ytick', [-1, 0, 1]); % (d) Sample rate conversion by 5/8: I = 5, D = 8
I = 5; D = 8; [y, h] = resample(x, I, D);
fprintf('\n The Length of filter is %d , and length of y is %d \n', length(h), length(y) ); subplot(2, 2, 4);
Hd = stem(m, y(m+k1*I/D+1), 'filled'); axis([-1, 33, -1.1, 1.1]); grid on;
set(Hd, 'markersize', 2); xlabel('n'); ylabel('Amplitude');
title('Sample rate I/D: I = 5, D = 8 ', 'fontsize', TF);
set(gca, 'xtick', [0, 10, 16, 32]);
set(gca, 'ytick', [-1, 0, 1]);

  运行结果:

三种不同采样率情况下对应的滤波器长度61、81、161是如何算出来的,我现在还不清楚,有知道的博友不吝赐教。在这里先谢谢了。

第1个采样率用3/2(大于1)转换,总体效果表现为插值。所得信号在一个周期内有16×3/2=24个采样点。

另外两个采样率变换因子都小于1,总体效果就表现为抽样,相应的一个周期内分别有16×3/4=12、16×5/8=10个采样点。

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

  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. apollo stomp client 代码示例

    0.环境准备 0.1.linux 0.2.java 0.3.下载apollo二进制包,解压 0.4.创建broker,名字为 userlog {APOLLO_HOME}/bin/apollo crea ...

  2. spark sql 窗口函数over partition by

    1.窗口函数需要使用hiveContext,故引入如下包 libraryDependencies += "org.apache.spark" %% "spark-core ...

  3. 浏览器DOM操作

    HTML Node 节点 常用API 高效遍历 DOM Repaint and reflow 插入大量内容避免重绘和回流 style 样式操作 DOM事件 HTML - innerHTML:内部HTM ...

  4. HDU6166-求集合间的最短路

    Senior Pan Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Tot ...

  5. js判断回车,判断焦点控件

    document.onkeydown=function(event){        e = event ? event :(window.event ? window.event : null);  ...

  6. wordpress启动

    wordpress启动 公司需要使用到wordpress 特意下载源码进行研究,才发现里面都是.php文件,需要运行php而不得不去配置运行环境 步骤如下 Wampserver32 使用的360安装的 ...

  7. 012——数组(十二) 数组range array_count_values array_pad array_product

    <?php /*range () 生成包含指定范围的数组,第三个参数是步长值 */ /*$arr=range(1,10,2); print_r($arr);//输出:Array ( [0] =& ...

  8. form表单序列化之后追加字段

    方法是在{}中添加字段 key-value 一一对应,如下: var data = $.param({'state': state}) + '&' + $('#desProForm').ser ...

  9. OpenVPN CreateProcess Failed 问题解决

    启动 OpenVPN GUI 时失败 显示如下信息 CreateProcess Failed, exe=’X:XXXXXOpenVPNbinopenvpn.exe’ cmdline=’openvpn ...

  10. Django中类视图使用装饰器的方式

    类视图使用装饰器 为类视图添加装饰器,可以使用两种方法. 为了理解方便,我们先来定义一个为函数视图准备的装饰器(在设计装饰器时基本都以函数视图作为考虑的被装饰对象),及一个要被装饰的类视图. def ...