Obtain and compare the magnitude spectrums of Hanning, Hamming and triangular wi
ID: 2080601 • Letter: O
Question
Obtain and compare the magnitude spectrums of Hanning, Hamming and triangular windowed 100 and 110 Hz signals using a 20-ms window for each using MATLAB as given in Fig 3.35 on Magnitude spectrum for 100-Hz signal (left) and 110-Hz signal (right). First row corresponds to the magnitude spectra from a 20-ms windowed signal. Second row corresponds to the magnitude spectra from a 60-ms windowed signal. The dashed lines in the figure correspond to the DTFT spectra, while the stars correspond to the DFT spectra.Explanation / Answer
%function [out] = window(win_size,type) %Input |%Output %win_size= no:of points in window |%out = window of length [win_size] %type = window type %Example Usage %win = window(2^4,'rectangular') %hanning %hamming %rectangular function [out] = window(win_size,type) res = ones(win_size,1); switch lower(type) case 'blackman' for i=0:1:win_size-1 res(i+1) = 0.42 - 0.5*cos(2*pi*i/(win_size-1)) + 0.08*cos(4*pi*i/(win_size -1)); end case 'flattop' a0=1; a1=1.93; a2=1.29; a3=0.338; a4=0.032; for i=0:1:win_size-1 res(i+1) = a0 - a1*cos(2*pi*i/(win_size-1)) + a2*cos(4*pi*i/(win_size -1))- a3*cos(6*pi*i/(win_size -1)) + a4*cos(8*pi*i/(win_size -1)); end case 'hanning' for i=0:1:win_size-1 res(i+1) = 0.5*(1 - cos(2*pi*i/(win_size-1))); end case 'hamming' for i=0:1:win_size-1 res(i+1) = 0.54 - 0.46*cos(2*pi*i/(win_size-1)); end case 'nuttall' a0=0.3635819; a1=0.4891775; a2=0.1365995; a3=0.0105411; a4=0.032; for i=0:1:win_size-1 res(i+1) = a0 - a1*cos(2*pi*i/(win_size-1)) + a2*cos(4*pi*i/(win_size -1))- a3*cos(6*pi*i/(win_size -1)); end otherwise end out = res; end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.