DSP using MATLAB 随书示例Example2.8

x = [3, 11, 7, 0, -1, 4, 2]; nx = [-3:3];
h = [2, 3, 0, -5, 2, 1]; nh = [-1:4]; [y,ny] = conv_m(x,nx,h,nh)
结果:
下面展示一些具体步骤:
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Exameple 2.8 \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);
%% ------------------------------------------------------------------------ % Input sequence
x = [3, 11, 7, 0, -1, 4, 2]; nx = [-3:3];
% Impulse Response sequence
h = [2, 3, 0, -5, 2, 1]; nh = [-1:4]; [y,ny] = conv_m(x,nx,h,nh) figure('NumberTitle', 'off', 'Name', 'Exameple 2.8')
set(gcf,'Color','white'); % x(k) and h(k)
subplot(2, 2, 1); stem(nx, x); axis([-5, 5, -6, 12]); grid on;
hold on;
stem(nh+0.1, h, 'r:');
a = axis; text(a(2)+0.5, a(3), 'k'); text(-1.5, 11, 'Solid :x Dashed :h');
title('x(k) & h(k)');
hold off; % x(k) and h(-k)
subplot(2, 2, 2); stem(nx, x);axis([-5, 5, -6, 12]); grid on;
hold on;
stem(-fliplr(nh)+0.1, fliplr(h), 'r:');
a = axis; text(a(2)+0.5, a(3), 'k'); text(-0.5, -1, 'n=0');
text(-1.5, 11, 'Solid :x Dashed :h');
title('x(k) and h(-k)');
hold off; % x(k) and h(-1-k)
subplot(2, 2, 3); stem(nx, x);axis([-5, 5, -6, 12]); grid on;
hold on;
stem(-fliplr(nh)+0.1-1, fliplr(h), 'r:');
a = axis; text(a(2)+0.5, a(3), 'k'); text(-1-0.5, -1, 'n=-1');
text(-1.5, 11, 'Solid :x Dashed :h');
title('x(k) and h(-1-k)');
hold off; % x(k) and h(2-k)
subplot(2, 2, 4); stem(nx, x);axis([-5, 5, -6, 12]); grid on;
hold on;
stem(-fliplr(nh)+0.1+2, fliplr(h), 'r:');
a = axis; text(a(2)+0.5, a(3), 'k'); text(2-0.5, -1, 'n=2');
text(-1.5, 11, 'Solid :x Dashed :h');
title('x(k) and h(2-k)');
hold off;
运行结果:

左上角是x(k)和h(k);右上角是x(k)和h(-k),对h(k)进行了反转;左下角是x(k)和h(-1-k),对h(k)进行了反转后再向左移一位;
右下角是x(k)和h(2-k),对h(k)进行了反转后再向右移两位;
DSP using MATLAB 随书示例Example2.8的更多相关文章
- 《DSP using MATLAB》示例Example 10.4
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》示例 Example 10.2
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》示例 Example 10.1
坚持到第10章了,继续努力! 代码: %% ------------------------------------------------------------------------ %% Ou ...
- 《DSP using MATLAB》 示例 Example 9.16
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》示例 Example 9.14
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》 示例 Example 9.12
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》示例 Example 9.11
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》示例 Example 9.10
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》示例Example 9.9
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
随机推荐
- SQL Server遍历表的几种方法 转载
SQL Server遍历表的几种方法 阅读目录 使用游标 使用表变量 使用临时表 在数据库开发过程中,我们经常会碰到要遍历数据表的情形,一提到遍历表,我们第一印象可能就想到使用游标,使用游标虽然直观易 ...
- mybatis参数错误 Parameter '×××' not found. Available parameters are [0, 1, param1, param2]
报错的代码 @Update("update staff_info set ApplyState = #{applyState} where Id = #{userId}") int ...
- 【Git】笔记5 分支管理2
来源:廖雪峰 通常,合并分支时,如果可能,Git会用Fast forward模式,但这种模式下,删除分支后,会丢掉分支信息. 如果要强制禁用Fast forward模式,Git就会在merge时生成一 ...
- IOS- 自定义 UIButton
#pragma mark init方法内部默认会调用initWithFrame: - (id)initWithFrame:(CGRect)frame { self = [super initWithF ...
- PHP安全编程:对输出要进行转义
为了区分数据是否已转义,我还是建议定义一个命名机制.对于输出到客户机的转义数据,我使用$html数组进行存储,该数据首先初始化成一个空数组,对所有已过滤和已转义数据进行保存. 1 <?php 2 ...
- 群内大神与你交流WEB经验 业内专家指点就职技巧
就知道你是一个有理想要抱负的人,不会满足于做一个初级的前端开发工程师.在接下来的这个阶段,我们将走上前端开发的进阶之路,将自己的能力再往上拔高一个等级.同样,薪资也会往上升一个等级!但是,如果你是一个 ...
- stm32——NFC芯片--PN532的使用
stm32——NFC芯片--PN532的使用 一.NFC简介 NFC(Near Field Communication)近场通信,是一种短距高频的无线电技术,在13.56MHz频率运行于20厘米距离内 ...
- 开启后台 Service 闪退
04-29 15:36:23.395: E/ActivityThread(15275): Performing stop of activity that is not resumed: {com.e ...
- Android-----overridePendingTransition的使用
1 Activity的切换动画指的是从一个activity跳转到另外一个activity时的动画. 它包括两个部分:一部分是第一个activity退出时的动画:另外一部分时第二个activity进入时 ...
- hdu 5108 Alexandra and Prime Numbers
数论题,本质是求出n的最大质因子 #include<time.h> #include <cstdio> #include <iostream> #include&l ...