File:Two 8-point Gaussian window functions.svg
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.svgCategory:Files with derivative versions |
| SVG development |
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:
| 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.
|
Category:CC-Zero
Category:Created with GNU Octave
Category:Files with derivative versions
Category:Images with Gnuplot source code
Category:Images with Octave source code
Category:SVG created also with GNUPLOT
Category:SVG images with embedded raster graphics
Category:Self-published work
Category:Valid SVG created with Octave
Category:Window function