《DSP using MATLAB》示例 Example 9.6

代码:
%% ------------------------------------------------------------------------
%% 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的更多相关文章
- 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.23
代码: % Discrete-time Signal x1(n) : Ts = 0.0002 Ts = 0.0002; n = -25:1:25; nTs = n*Ts; x1 = exp(-1000 ...
- 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 ...
- DSP using MATLAB 示例Example3.17
- 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, ...
- 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 ...
- 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 ...
- 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 , ...
随机推荐
- 一些putty的应用设置
把windows下putty的key转换成linux上使用的rsa key http://ask.apelearn.com/question/937 putty生成的密钥导入connectbot ...
- spark 性能优化
1.内存 spark.storage.memoryFraction:很明显,是指spark缓存的大小,默认比例0.6 spark.shuffle.memoryFraction:管理executor中R ...
- .net core mvc部署到IIS导出Word 提示80070005拒绝访问
项目中相信大家经常会遇到导出Word.Excel等需求,在实际开发环境中,一般不会出现什么问题,但当发布到IIS上后可能会遇到各种各样的问题,一般都是权限的问题.前几天把公司项目发布后,出现Word导 ...
- Linux系统 SSHD服务安全优化方案
# 1. 修改默认端口 #Port 22 # 2. 修改监听协议,只监听某个或某些网络协议 #AddressFamily any AddressFamily inet # 3. 修改ssh只监听内 ...
- Docker 生态
Docker 和容器技术的发展可谓是日新月异,本文试图以全局的视角来梳理一下 docker 目前的生态圈.既然是概览,所以不会涉及具体的技术细节. Docker 自从发布以来发生了很多的变化,并且有些 ...
- spoj-ASSIGN-bitDP
ASSIGN - Assignments #dynamic-programming Problem Your task will be to calculate number of different ...
- grub2 windows版安装
一.BIOS方式,grub2安装 查看磁盘情况 E:\grub-2.02-for-windows>wmic diskdrive list brief Caption DeviceID Model ...
- 时间处理模块time
一.时间概念 1.1 时间戳 时间戳是指格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总 秒数.通俗的讲, 时间戳是一份能够表示一份 ...
- 【zzuli-2276】跳一跳
题目描述 今天跳跳去公园游玩,第一个游戏就难倒了跳跳,游戏规则是跳跳站在一个面积无限大的矩形土地上,开始时跳跳在左上角(即第一行第一列),每一次跳跳都可以选择一个右下方格子,并瞬间跳过去(如从下图中的 ...
- 微信小程序单个倒计时效果
var end_time = grouponList.expire_time.replace(/-/g, '/') grouponcountdown(that, end_time) //适用于商品列表 ...