• DSP using MATlAB 示例Example2.10


    上代码

    % noise sequence 1
    x = [3, 11, 7, 0, -1, 4, 2]; nx = [-3:3];            % given signal x(n)
    [y,ny] = sigshift(x,nx,2);                           % obtain x(n-2)
    
    set(gcf,'Color','white')
    subplot(2,1,1);stem(nx,x); title('sequence x(n)');
    xlabel('n');ylabel('x(n)'); grid on
    subplot(2,1,2);stem(ny,y);title('sequence x(n-2)')
    xlabel('n');ylabel('x(n-2)'); grid on
    
    w = randn(1,length(y)); nw = ny;                     % generate w(n)
    [y,ny] = sigadd(y,ny,w,nw);                          % obtain y(n)=x(n-2)+w(n)
    [x,nx] = sigfold(x,nx);                              % obtain x(-n)
    [rxy,nrxy] = conv_m(y,ny,x,nx);                      % crosscorrelation
    
    figure
    set(gcf,'Color','white')
    subplot(1,1,1), subplot(2,1,1); stem(nrxy,rxy);
    axis([-5,10,-50,250]); xlabel('lag variable 1')
    ylabel('rxy'); title('crosscorrelation: noise sequence 1')
    grid on
    %
    % noise sequence 2
    x = [3, 11, 7, 0, -1, 4, 2]; nx = [-3:3];            % given signal x(n)
    [y,ny] = sigshift(x,nx,2);                           % obtain x(n-2)
    w = randn(1,length(y)); nw = ny;                     % generate w(n)
    [y,ny] = sigadd(y,ny,w,nw);                          % obtain y(n)=x(n-2)+w(n)
    [x,nx] = sigfold(x,nx);                              % obtain x(-n)
    [rxy,nrxy] = conv_m(y,ny,x,nx);                      % crosscorrelation
    subplot(2,1,2); stem(nrxy,rxy)
    axis([-5,10,-50,250]);xlabel('lag variable 1')
    ylabel('rxy'); title('crosscorrelation: noise sequence 2')
    grid on
    

    结果:

      

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    JavaScript autoComplete 1.2
    Linux下安装配置git
    《SQL Server 2008从入门到精通》20180627
    《SQL必知必会》知识点汇总
    关于js的setTimeout和setInterval
    关于js的闭包
    web图片类型
    关于绑定事件
    js原型与继承
    关于js的mouseout
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/6028701.html
Copyright © 2020-2023  润新知