File:Two 8-point Gaussian window functions.svg

From testwiki
Jump to navigation Jump to search
    Original file (SVG file, nominally 652 × 372 pixels, file size: 36 KB)

    This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.

    Summary

    Description
    English: Two different ways to generate Gaussian window functions (σ=0.4) for spectral analysis applications. MATLAB calls them "symmetric" and "periodic". The latter is also called "DFT Even" in the classic Frederic Harris paper.
    Date
    Source Own work
    Author Bob K
    Other versions Derivative works of this file:  Comparison of symmetric and periodic Gaussian windows.svg
    SVG development
    InfoField
     The SVG code is valid.
    V
     This vector image was created with GNU Octave.
     and with GNUPLOT.

    Source code

    This graphic was created by the following Octave script:

    pkg load signal
    graphics_toolkit gnuplot
    clear all; close all; clc
    function out=gauss(sigma,M)
    out=exp(-.5*(((0:M)-M/2)/(sigma*M/2)).^2);
    endfunction
    
     M=5600;        % big number, divisible by 7 and 8
     window = gauss(0.4,M);   % M+1 samples of a Gaussian window
     N=8;           % actual window size, in "hops"
    
    % Sample the window.
    % Scale the abscissa. 0:M samples --> 0:7 "hops", and take 8 symmetrical hops, from 0 to 7
     sam_per_hop_7 = M/7;
    %symmetric8 = window(1+(0:7)*sam_per_hop_7);
     symmetric8 = exp(-.5*(((0:7)-7/2)/(.4*7/2)).^2); % Equivalent method
    
    % Scale the abscissa. 0:M samples --> 0:8 "hops", and take 8 asymmetrical hops, from 0 to 7
     sam_per_hop_8 = M/8;
    %periodic8 = window(1+(0:7)*sam_per_hop_8);
     periodic8 = exp(-.5*(((0:7)-8/2)/(.4*8/2)).^2); % Equivalent method
    
    % Compare equivalent noise bandwidths (info only)
     ENBW_symmetric8 = N*sum(symmetric8.^2)/sum(symmetric8)^2                            % 1.6233
     ENBW_periodic8  = N*sum(periodic8.^2) /sum(periodic8)^2                             % 1.4533
    
    %------------------------------------------------------------------
    % Plot the points
    figure("position", [100 200 700 400])
    
     plot(0:7, symmetric8,  "color","red",   ".", "markersize",14)
     hold on
     plot(0:7, periodic8,   "color","blue",  ".", "markersize",14)
    
    % Connect the dots
     hops = (0:M)/sam_per_hop_8;
     plot(hops, window, "color","blue")          % periodic
    
     hops = (0:M)/sam_per_hop_7;
     plot(hops, window, "color","red")           % symmetric
    
    xlim([0 8])
    set(gca, "xgrid","on")
    set(gca, "ygrid","on")
    set(gca, "ytick",[0:.25:1])
    set(gca, "xtick",[0:8])
    
    title("Two 8-point Gaussian window functions", "fontsize",14, "fontweight","normal");
    xlabel('\leftarrow  n  \rightarrow', "fontsize",14)
    
    text(2.96, .56, 'Matlab "symmetric" \rightarrow', 'color', 'red', 'FontSize',12)
    str = {'\leftarrow Matlab "periodic"','     ("DFT-even")'};
    text(5.1, .813, str, 'color', 'blue', 'FontSize',12)
    
    #{
    % After this call, the cursor units change to a normalized ([0,1]) coordinate system
    % Draw an annotated right-to-left arrow.
    annotation("textarrow", [.683 .644], [.738 .738],...
            "color", "blue", "string", {'Matlab "periodic"','     ("DFT-even")'}, "fontsize",10,...
            "linewidth",1, "headstyle","vback1", "headlength",5, "headwidth",5)
    
    % Draw an annotated left-to-right arrow.
    % Bug alert:  Unlike the right-to-left arrow, it centers the text at the arrow start point.
    % So the string of blanks in the 1st continuation line is a work-around for that.  
    annotation("textarrow", [.565 .62], [.542 .542],...
            "color", "red", "string", {'Matlab "symmetric"            '}, "fontsize",10,...
            "linewidth",1, "headstyle","vback1", "headlength",5, "headwidth",5)
    #}
    

    Licensing

    Bob K, the copyright holder of this work, hereby publishes it under the following license:
    Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
    The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

    Captions

    Add a one-line explanation of what this file represents

    Items portrayed in this file

    depicts

    28 September 2019

    37,274 byte

    image/svg+xml

    55af70465a70a5b92819646c41b4e3f4ac2a3aa0

    File history

    Click on a date/time to view the file as it appeared at that time.

    Date/TimeThumbnailDimensionsUserComment
    current02:42, 29 September 2019Thumbnail for version as of 02:42, 29 September 2019652 × 372 (36 KB)wikimediacommons>Bob Kincrease size of annotation font

    There are no pages that use this file.