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的更多相关文章

  1. 《DSP using MATLAB》示例Example 10.4

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  2. 《DSP using MATLAB》示例 Example 10.2

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  3. 《DSP using MATLAB》示例 Example 10.1

    坚持到第10章了,继续努力! 代码: %% ------------------------------------------------------------------------ %% Ou ...

  4. 《DSP using MATLAB》 示例 Example 9.16

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  5. 《DSP using MATLAB》示例 Example 9.14

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  6. 《DSP using MATLAB》 示例 Example 9.12

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  7. 《DSP using MATLAB》示例 Example 9.11

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  8. 《DSP using MATLAB》示例 Example 9.10

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  9. 《DSP using MATLAB》示例Example 9.9

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

随机推荐

  1. BestCoder19 1001.Alexandra and Prime Numbers(hdu 5108) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5108 题目意思:给出一个数正整数 N,N <= 1e9,现在需要找出一个最少的正整数 M,使得 ...

  2. 【xml】利用OpenCV解析

    看到一篇讲的很清楚的博客:http://blog.csdn.net/jarvischu/article/details/8481510

  3. $.each 和$(selector).each()的区别

    $.each() 对数组或对对象内容进行循环处理 jQuery.each( collection, callback(indexInArray, valueOfElement) ) collectio ...

  4. css 自动换行 [英文、数字、中文]

    white-space:normal;overflow: auto;table-layout:fixed; word-break: break-all;

  5. 第一次点击Div1显示Div2,再次点击Div1的时候又隐藏Div2

    要使用Jquery来实现,记得引用Jquery库哦,代码如下: $(document).ready(function(){ $("#ck1").click(function(){ ...

  6. 在R语言中无法设置CRAN镜像问题

    很大的可能是因为使用的浏览器不是IE浏览器的问题,因为CRAN的镜像需要用IE浏览器来打开. 只需要按照下面设置即可: 1.打开IE-->设置-->Internet选项-->高级 2 ...

  7. 51nod1066(bash博弈)

    题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1066 题意:中文题诶- 思路:感觉博弈全靠yy- 在双方都没有 ...

  8. sys.sysprocesses视图的使用小结

    Sys.SysProcesses 系统表是一个很重要的系统视图,主要用来定位与解决Sql Server的阻塞和死锁包含正在 SQL Server 实例上运行的进程的相关信息.这些进程可以是客户端进程或 ...

  9. nfs 是Network File System 网络文件系统

    NFS的基本原刚是容许不同的客户端及服务通过一组PRC分享相同的文件系统,它是独立于操作系统,容许不同硬件及操作系统的系统共同进行文件的分享.NFS在文件传送过程中依赖于RPC协议.远程过程调用Rem ...

  10. C#的事件

    using System; using System.Collections; using System.Collections.Generic; using System.IO; namespace ...