《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 , ...
随机推荐
- MySQL Order By Rand()效率分析
最近研究了一下MYSQL的随机抽取实现方法.举个例子,要从tablename表中随机提取一条记录,大家一般的写法就是:SELECT * FROM tablename ORDER BY RAND() L ...
- Android显示框架:自定义View实践之绘制篇
文章目录 一 View 二 Paint 2.1 颜色处理 2.2 文字处理 2.3 特殊处理 三 Canvas 3.1 界面绘制 3.2 范围裁切 3.3 集合变换 四 Path 4.1 添加图形 4 ...
- 浏览器DOM操作
HTML Node 节点 常用API 高效遍历 DOM Repaint and reflow 插入大量内容避免重绘和回流 style 样式操作 DOM事件 HTML - innerHTML:内部HTM ...
- Python+Opencv进行识别相似图片
http://blog.csdn.net/feimengjuan/article/details/51279629
- 1-16-2 LVM管理和ssm存储管理器使用&磁盘配额
ssm存储管理器使用&磁盘配额 ssm存储管理器使用 系统存储管理器的使用 系统存储管理器(又称ssm,即system-storage-manager),是RHEL7/CentOS7新增的功能 ...
- IOS-OC 编码建议
“神在细节之中” Objective-C 是 C 语言的扩展,增加了动态类型和面对对象的特性.它被设计成具有易读易用的,支持复杂的面向对象设计的编程语言.它是 Mac OS X 以及 iPhone 的 ...
- 利用expect和sshpass完美非交互性执行远端命令
yum install expect -y expect 参考:http://blog.csdn.net/snow_114/article/details/53245466 yum install s ...
- MySQL20个经典面试题
MySQL20个经典面试题 Part2:经典题目 1.MySQL的复制原理以及流程 基本原理流程,3个线程以及之间的关联: 2.MySQL中myisam与innodb的区别,至少5点 (1).问5点不 ...
- certbot以standalone方式新建密钥
下载:wget https://dl.eff.org/certbot-auto 授权:chmod a+x ./certbot-auto 快捷命令 ./certbot-auto certonly --t ...
- C++设计模式之-外观模式
意图: 为子系统中的一组接口提供一个一致的界面,此模式定义了一个高层接口,这个接口使得这一系统更加容易使用. 适用性: 1.在设计初期阶段,应该要有意识的将不同的两个层分离,比如经典的三层架构,就需要 ...