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. 【leetcode】Count Primes(easy)

    Count the number of prime numbers less than a non-negative number, n 思路:数质数的个数 开始写了个蛮力的,存储已有质数,判断新数字 ...

  2. 2048控制台程序:一份帝国理工C++作业

    #include <fstream> #include <vector> #include <iostream> #include <string> u ...

  3. October 14th 2016 Week 42nd Friday

    Who am I? Coming October 18, 2016! 我是谁?2016.10.18 拭目以待! Don't worry. You will be a wow. Don't worry. ...

  4. css3属性flex弹性布局设置三列(四列)分布样式

    参考:阮一峰的网络日志 <!doctype html> <html lang="en"> <head> <meta charset=&qu ...

  5. vs2013中项目依赖项的作用

    依赖项就是设定项目所以来的项目,以决定具体生成解决方案时,项目编译的顺序(一般一个解决方案会有很多项目组成). 通常来说,依赖项取决于这个项目引用的组件和项目,系统可以自己决定. 作用就是让系统知道你 ...

  6. python异步爬虫

    本文主要包括以下内容 线程池实现并发爬虫 回调方法实现异步爬虫 协程技术的介绍 一个基于协程的异步编程模型 协程实现异步爬虫 线程池.回调.协程 我们希望通过并发执行来加快爬虫抓取页面的速度.一般的实 ...

  7. php 投票系统练习

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  8. Feature hashing相关 - 2

    Bloom filter     思路 用多个不同hash 来记录,比如遇到一个 love 有4个hash function 映射到4个bit位置,如果所有位置都是1 那么认为之前已经遇到love这个 ...

  9. svn删除所有.svn文件

    svn 删除所有的 .svn文件 find . -name .svn -type d -exec rm -fr {} \;

  10. MVC:Control与View传值

    MVC页面传值的方式主要有三种: 第一种: 采用ViewData.采用键值对的方式,ViewData存储的是一个object类型,传到view层需要强类型转换:使用起来类似于字典集合模式: ViewD ...