zoukankan      html  css  js  c++  java
  • 《DSP using MATLAB》Problem 4.8

    代码:

    %% ----------------------------------------------------------------------------
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Problem 4.8 
    
    ');
    
    banner();
    %% ----------------------------------------------------------------------------
    
    
    %% -----------------------------------------------------
    %%             x3(n)=x1(n)*x2(n)
    %%          sigma(x3)=[sigma(x1)] [sigma(x2)]
    %% -----------------------------------------------------
    num = 10;
    x1 = 0 + (2-0)*rand(1, 2*num+1);
    n1 = [-num:num];
    sum_x1 = sum(x1(:))
    
    x2 = 0 + (2-0)*rand(1, 2*num+1);
    n2 = [-num:num];
    sum_x2 = sum(x2(:))
    
    figure('NumberTitle', 'off', 'Name', 'Problem 4.8 Sequence x1 and x2');
    set(gcf,'Color','white'); 
    %hist(x1,x_axis); 
    subplot(2,1,1); stem(n1, x1);
    title('Uniformly Distributed Random Numbers x1(n)');
    xlabel('n'); ylabel('x1(n)'); grid on;
    subplot(2,1,2); stem(n2, x2);
    title('Uniformly Distributed Random Numbers x2(n)');
    xlabel('n'); ylabel('x2(n)'); grid on;
    
    
    [x3, n3] = conv_m(x1, n1, x2, n2);
    sum_x3 = sum(x3(:))
    sum_chk = sum_x1 * sum_x2
    
    figure('NumberTitle', 'off', 'Name', 'Problem 4.8 Sequence x3');
    set(gcf,'Color','white'); 
    %hist(x1,x_axis); 
    %subplot(2,1,1); 
    stem(n3, x3);
    title('Sequence x3(n)=x1*x2 ');
    xlabel('n'); ylabel('x3(n)'); grid on;
    

      运行结果:

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    第3周 实践项目2 建设”顺序表“算法库(可参考为模板)
    第3周实践项目3 求集合并集
    【luogu 2529】【SHOI 2001】击鼓传花
    【BZOJ 3270】博物馆
    【BZOJ 2337】XOR和路径
    浅谈期望dp
    【codeforces 24D】Broken Robot
    【POJ 1463】Strategic game
    【POJ 3585】Accumulation Degree
    【luogu 3146/3147】248/262144
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/8436672.html
Copyright © 2011-2022 走看看