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

    1、代码:

    从MATLAB官方网上下载的。

    %*************************************************************************%
    %A code for the Downsampler%
    %Author: Yashwant Marathe%
    %Date:20-12-2010%
    function [y ny] = dnsample(x,n,M)
    %x is a sequence over indices specified by vector n,M is the downsampling factor.
    
    param=n/M;
    %generates the parameter vector.This vector will decide which input samples will be present in the output.
    
    samp=fix(param)==param;
    %only those output vectors corresponding to indices where samp==1 will be present in the output.
    
    y=x(samp==1);
    %generates the output sequence
    
    ny=n(samp==1)/M;
    %generates the indices of the output sequence
    
    end
    %**************************************************************************

    2、代码

    %% ------------------------------------------------------------------------
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Problem 2.8.2 
    
    ');
    
    banner();
    %% ------------------------------------------------------------------------
    
    n = [-50:1:50]; 
    x = sin( 0.125 * pi * n ); 
    
    M = 4;
    
    [y, m] = dnsample(x, n, M);
    
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.8.2')
    set(gcf,'Color',[1,1,1])                  % 改变坐标外围背景颜色
    
    subplot(2,1,1); stem(n, x); title('x sequence');
    xlabel('n'); ylabel('x(n)') ;
    grid on
    subplot(2,1,2); stem(m, y); title('y sequence');
    xlabel('n'); ylabel('y(m)');
    grid on;
    

      运行结果:

    3、代码

    %% ------------------------------------------------------------------------
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Problem 2.8.3 
    
    ');
    
    banner();
    %% ------------------------------------------------------------------------
    
    n = [-50:1:50]; 
    x = sin( 0.5 * pi * n ); 
    
    M = 4;
    
    [y, m] = dnsample(x, n, M);
    
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.8.3')
    set(gcf,'Color',[1,1,1])                  % 改变坐标外围背景颜色
    
    subplot(2,1,1); stem(n, x); title('x sequence');
    xlabel('n'); ylabel('x(n)') ;
    grid on
    subplot(2,1,2); stem(m, y); title('y sequence');
    xlabel('n'); ylabel('y(m)');
    grid on;
    

      运行结果:

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    定位图片的特殊例子+上传图片
    mysql 视图 安全性( mysql 表能读,但是视图不能读问题 )
    关于mysql 的 autoCommit 参数
    @Transactional 可以写在 Controller 方法上面了
    微信 支付宝 同时支付一个订单的解决方案
    Illegalmixofcollations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT)foroperation '= 连表查询排序规则问题
    Transaction rolled back because it has been marked as rollback-only 原因 和解决方案
    RabbitMQ 死信队列 延时
    好久没考虑过的 sql 注入
    基于redis的 分布式锁 Java实现
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/7990073.html
Copyright © 2011-2022 走看看