代码:

%% ------------------------------------------------------------------------
%% 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. jquery中的工具方法$.isFunction, $.isArray(), $.isWindow()

    本文正式地址:http://www.xiabingbao.com/jquery/2015/07/25/jquery-judge-type 在javascript中对变量类型的判断中,我们讲解了了jqu ...

  2. phalcon: 目录分组后的acl权限控制

    phalcon: 目录分组后的acl权限控制 楼主在做acl权限的时候,发现官方的acl只能针对未分组的目录,如下: app/ ___|./controller ___|./logic ___|./p ...

  3. 手动建立Mysql表实体类技巧

    首先执行一条sql语句,也可以在开发中插入数据.修改数据或者查询数据的某个属性时使用. select sc.COLUMN_NAME from information_schema.COLUMNS as ...

  4. 玲珑oj 1128 RMQ模板

    1128 - 咸鱼拷问 Time Limit:3s Memory Limit:128MByte Submissions:380Solved:118 DESCRIPTION 给你两个序列A,B.每个序列 ...

  5. IOS UI-UISearchController

    ViewController.m // // ViewController.m // IOS_0224_查找联系人 // // Created by ma c on 16/2/24. // Copyr ...

  6. Django 前后台的数据传递示列

    Django 前后台的数据传递的方法 Django 从后台往前台传递数据时有多种方法可以实现. 最简单的后台是这样的: ? 1 2 3 4 from django.shortcuts import r ...

  7. Python中实现switchcase

    # 第一种方式使用python中的字典# author:wanstack def first_func(): print('first_func') def second_func(): print( ...

  8. HDU 4549 M斐波那契数列(矩阵快速幂+费马小定理)

    M斐波那契数列 Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other) Total Submi ...

  9. LeetCode OJ:Regular Expression Matching(正则表达式匹配)

    Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...

  10. Slice Header中的field_pic_flag的含义?

    编码模式指帧编码.场编码.帧场自适应编码.当这个句法元素取值为1时属于场编码:0为非场编码. 序列参数集中的句法元素frame_mbs_only_flag和mb_adaptive_frame_fiel ...