zoukankan      html  css  js  c++  java
  • 《DSP using MATLAB》示例Example5.2

    代码:

    L = 5; N = 20; k = [-N/2:N/2];               % square wave parameters
    xn = [ones(1,L), zeros(1,N-L)];              % Sq wave x(n) 
    Xk = dfs(xn,N);                              % DFS
    
    %% ----------------------------------------------------
    %%      START      periodic sequence
    %% ----------------------------------------------------
    self_periods = N;
    periods = 3;
    n1 = [-20: -1 + (periods-1) * self_periods];
    
    xtilde = xn' * ones(1,periods); xtilde = (xtilde(:))';
    
    figure('NumberTitle', 'off', 'Name', 'Example5.2  3 Period Sequence')
    set(gcf,'Color','white');
    stem(n1,xtilde); title('Three Peroids of xtilde(n)');axis([-20, 40, -0.5, 1.5]);
    xlabel('n'); ylabel('xtilde(n)');grid on;
    %% ----------------------------------------------------
    %%      END     periodic sequence
    %% ----------------------------------------------------
    
    magXk = abs([Xk(N/2+1:N) Xk(1:N/2+1)]);      % DFS magnitude
    
    figure('NumberTitle', 'off', 'Name', 'Example5.2')
    set(gcf,'Color','white'); 
    subplot(2,2,1); stem(k, magXk); axis([-N/2, N/2, -0.5, 5.5]);
    xlabel('k'); ylabel('Xtilde(k)'); grid on;
    title('DFS of SQ. wave: L=5 N=20');
    
    L = 5; N = 40; k = [-N/2:N/2];               % square wave parameters
    xn = [ones(1,L), zeros(1,N-L)];              % Sq wave x(n) 
    Xk = dfs(xn,N);                              % DFS
    
    magXk = abs([Xk(N/2+1:N) Xk(1:N/2+1)]);      % DFS magnitude
    
    %figure('NumberTitle', 'off', 'Name', 'Example5.2')
    %set(gcf,'Color','white'); 
    subplot(2,2,2); stem(k, magXk); axis([-N/2, N/2, -0.5, 5.5]);
    xlabel('k'); ylabel('Xtilde(k)'); grid on;
    title('DFS of SQ. wave: L=5 N=40');
    
    L = 5; N = 60; k = [-N/2:N/2];               % square wave parameters
    xn = [ones(1,L), zeros(1,N-L)];              % Sq wave x(n) 
    Xk = dfs(xn,N);                              % DFS
    
    magXk = abs([Xk(N/2+1:N) Xk(1:N/2+1)]);      % DFS magnitude
    
    %figure('NumberTitle', 'off', 'Name', 'Example5.2')
    %set(gcf,'Color','white'); 
    subplot(2,2,3); stem(k, magXk); axis([-N/2, N/2, -0.5, 5.5]);
    xlabel('k'); ylabel('Xtilde(k)'); grid on;
    title('DFS of SQ. wave: L=5 N=60');
    
    L = 7; N = 60; k = [-N/2:N/2];               % square wave parameters
    xn = [ones(1,L), zeros(1,N-L)];              % Sq wave x(n) 
    Xk = dfs(xn,N);                              % DFS
    
    magXk = abs([Xk(N/2+1:N) Xk(1:N/2+1)]);      % DFS magnitude
    
    %figure('NumberTitle', 'off', 'Name', 'Example5.2')
    %set(gcf,'Color','white'); 
    subplot(2,2,4); stem(k, magXk); axis([-N/2, N/2, -0.5, 7.5]);
    xlabel('k'); ylabel('Xtilde(k)'); grid on;
    title('DFS of SQ. wave: L=7 N=60');
    

      运行结果:

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    监控mysql的存储引擎
    基于复制的高可用
    No orientation specified, and the default is
    iOS 图标、图形尺寸? iPhone、iPad、 iPod touch
    cocos2d-x3.9利用cocos引擎一键打包Android平台APK(C++小白教程)
    loaded some nib but the view outlet was not set
    IOS开发:UIAlertView使用
    UIAlertView笔记
    Xcode之外的文档浏览工具--Dash (在iOS代码库中浏览本帖)
    iOS 开发者能用上的 10 个 Xcode 插件
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/6127990.html
Copyright © 2011-2022 走看看