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. eclipse下使用git下载和上传项目

    简单配置,填入我们的用户名和邮箱 >>Preferences>Team>Git>Configuration 点击Add Entry,在弹出框里面输入key和value的值 ...

  2. 【数据结构】book3_3 表达式求值

    #include<iostream> #include <stdlib.h> using namespace std; typedef int Status; ; ; ; ; ...

  3. 【XLL API 函数】xlSheetNm

    从外部引用包含的工作表ID返回工作表或宏表名称,或是当前表名称. 原型 Excel12(xlSheetNm, LPXLOPER12 pxRes, 1, LPXLOPER12 pxExtref); 参数 ...

  4. September 8th 2016 Week 37th Thursday

    The secret of high-impact business is early preparation. 高效商务,赢在未雨绸缪. Early and best preparation is ...

  5. 解决At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this log

    pom增加:<dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</art ...

  6. Mysql相关集锦

    1.MyBatis中设置或获取插入的自增主键 http://my.oschina.net/kolbe/blog/512904 2.MySql性能调优与架构设计系列 http://www.cnblogs ...

  7. lsof

    lsof `which httpd` //那个进程在使用apache的可执行文件 lsof /etc/passwd //那个进程在占用/etc/passwd lsof /dev/hda6 //那个进程 ...

  8. Swift - 简单封装一个工具类模板

    创建模板类(封装一个类) 例1:新建一个名字叫做 Product 的类 Product.swift File 的内容 class Product { var name: String var desc ...

  9. hdu 1005

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1005 思路:找规律题 #include<stdio.h> main() { ]; int ...

  10. jdbc连接oracle数据库

    /*** 通过改变配置文件来连接不同数据库*/package com.xykj.jdbc; import static org.junit.Assert.*; import java.io.Input ...