• 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('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Exameple 2.8 
    
    ');
    
    time_stamp = datestr(now, 31);
    [wkd1, wkd2] = weekday(today, 'long');
    fprintf('      Now is %20s, and it is %7s  
    
    ', 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)进行了反转后再向右移两位;

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    保留两位小数 只能数字或小数 只能有一个小数点并且第一位不能为小数点的正则表达式
    Vue数据改变页面不更新 使用this.$set()强制更新的用法
    给对象新增属性
    vue-element的<el-tooltip>气泡提示失效问题
    vue刷新更新子组件
    watch监控对象
    vue-element-admin的api的js文件 get, post, put, delelt传参
    git 还原到某个版本
    在64位Win7系统中配置jsp开发环境以及一些问题解决方案
    在64位Win7系统中配置Apache+Mysql+PHP环境以及一些问题解决方案
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/6024908.html
Copyright © 2020-2023  润新知