• 《DSP using MATLAB》Problem 2.6


    1、代码

    %% ------------------------------------------------------------------------
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Problem 2.6.1 
    
    ');
    
    [v, d] = version;
    fprintf('    MATLAB Version: %20s
    
    ', v);
    fprintf('     Released Date: %17s
    
    ', d);
    
    time_stamp = datestr(now, 31);
    [wkd1, wkd2] = weekday(today, 'long');
    fprintf('      Today is %7s, and Now is %20s   
    
    ', wkd2, time_stamp);
    %% ------------------------------------------------------------------------
    
    
    
    n = [0:9]; 
    %x = stepseq(0,0,10) - stepseq(10,0,10); 
    x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
    [xe,xo,m] = evenodd(x,n);
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.6')
    set(gcf,'Color',[1,1,1])                  % 改变坐标外围背景颜色
    stem(n,x); title('x sequence ');
    xlabel('n'); ylabel('x(n)') ;
    % axis([-10,10,0,1.2])
    grid on
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.6')
    set(gcf,'Color',[1,1,1]) 
    stem(m,xe); title('Even Part');
    xlabel('n'); ylabel('xe(n)'); 
    %axis([-10,10,0,1.2])
    grid on
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.6')
    set(gcf,'Color','white')
    stem(m,xo); title('Odd Part');
    xlabel('n'); ylabel('xo(n)'); 
    %axis([-10,10,-0.6,0.6])
    grid on
    

      运行结果:

    2、代码

    %% ------------------------------------------------------------------------
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Problem 2.6.2 
    
    ');
    
    [v, d] = version;
    fprintf('    MATLAB Version: %20s
    
    ', v);
    fprintf('     Released Date: %17s
    
    ', d);
    
    time_stamp = datestr(now, 31);
    [wkd1, wkd2] = weekday(today, 'long');
    fprintf('      Today is %7s, and Now is %20s   
    
    ', wkd2, time_stamp);
    %% ------------------------------------------------------------------------
    
    n = [-5:10]; 
    x = exp(0.1 * n) .* (stepseq(-5,-5,10) - stepseq(10,-5,10)); 
    
    [xe,xo,m] = evenodd(x,n);
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.6')
    set(gcf,'Color',[1,1,1])                  % 改变坐标外围背景颜色
    stem(n,x); title('x sequence ');
    xlabel('n'); ylabel('x(n)') ;
    % axis([-10,10,0,1.2])
    grid on
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.6')
    set(gcf,'Color',[1,1,1]) 
    stem(m,xe); title('Even Part');
    xlabel('n'); ylabel('xe(n)'); 
    %axis([-10,10,0,1.2])
    grid on
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.6')
    set(gcf,'Color','white')
    stem(m,xo); title('Odd Part');
    xlabel('n'); ylabel('xo(n)'); 
    %axis([-10,10,-0.6,0.6])
    grid on
    

      运行结果:

    3、代码

    %% ------------------------------------------------------------------------
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Problem 2.6.3 
    
    ');
    
    [v, d] = version;
    fprintf('    MATLAB Version: %20s
    
    ', v);
    fprintf('     Released Date: %17s
    
    ', d);
    
    time_stamp = datestr(now, 31);
    [wkd1, wkd2] = weekday(today, 'long');
    fprintf('      Today is %7s, and Now is %20s   
    
    ', wkd2, time_stamp);
    %% ------------------------------------------------------------------------
    
    n = [-20:20]; 
    x = cos(0.2 * pi * n + pi/4); 
    
    [xe,xo,m] = evenodd(x,n);
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.6')
    set(gcf,'Color',[1,1,1])                  % 改变坐标外围背景颜色
    stem(n,x); title('x sequence ');
    xlabel('n'); ylabel('x(n)') ;
    % axis([-10,10,0,1.2])
    grid on
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.6')
    set(gcf,'Color',[1,1,1]) 
    stem(m,xe); title('Even Part');
    xlabel('n'); ylabel('xe(n)'); 
    %axis([-10,10,0,1.2])
    grid on
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.6')
    set(gcf,'Color','white')
    stem(m,xo); title('Odd Part');
    xlabel('n'); ylabel('xo(n)'); 
    %axis([-10,10,-0.6,0.6])
    grid on
    

      运行结果:

    4、代码

    %% ------------------------------------------------------------------------
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Problem 2.6.4 
    
    ');
    
    [v, d] = version;
    fprintf('    MATLAB Version: %20s
    
    ', v);
    fprintf('     Released Date: %17s
    
    ', d);
    
    time_stamp = datestr(now, 31);
    [wkd1, wkd2] = weekday(today, 'long');
    fprintf('      Today is %7s, and Now is %20s   
    
    ', wkd2, time_stamp);
    %% ------------------------------------------------------------------------
    
    n = [0:100]; 
    x = exp(-0.05 * n) .* sin(0.1 * pi * n + pi/3); 
    
    [xe,xo,m] = evenodd(x,n);
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.6')
    set(gcf,'Color',[1,1,1])                  % 改变坐标外围背景颜色
    stem(n,x); title('x sequence ');
    xlabel('n'); ylabel('x(n)') ;
    % axis([-10,10,0,1.2])
    grid on
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.6')
    set(gcf,'Color',[1,1,1]) 
    stem(m,xe); title('Even Part');
    xlabel('n'); ylabel('xe(n)'); 
    %axis([-10,10,0,1.2])
    grid on
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.6')
    set(gcf,'Color','white')
    stem(m,xo); title('Odd Part');
    xlabel('n'); ylabel('xo(n)'); 
    %axis([-10,10,-0.6,0.6])
    grid on
    

      运行结果:

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    java中static的用法
    java策略设计模式
    java模板设计模式
    Spring 学习笔记 8. 尚硅谷_佟刚_Spring_使用外部属性文件
    Spring 学习笔记 7. 尚硅谷_佟刚_Spring_Bean 的作用域
    Spring学习笔记 6. 尚硅谷_佟刚_Spring_Bean 之间的关系
    Spring学习笔记 5. 尚硅谷_佟刚_Spring_自动装配
    Spring 学习笔记 4. 尚硅谷_佟刚_Spring_属性配置细节
    Spring 学习笔记 3. 尚硅谷_佟刚_Spring_配置 Bean
    Spring 学习笔记 2. 尚硅谷_佟刚_Spring_IOC&DI概述
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/7967348.html
Copyright © 2020-2023  润新知