Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear all; close all; clc; %Cleaning up
- %Task:
- %In Matlab, plot the Hann- and Hamming window in the frequency domain with
- %window length N=41 by numerically calculating the Fourier transform.
- %Notes:
- %This code only features the Hann window for simplicity
- %Demonstration function for comparison:
- L = 41;
- wvtool(hann(L))
- %Task Properties
- N=41; %Data points
- SEGMENTS=1000; %Segments for the transform. Minimum of 200. Around 4101 yields no -Inf through testing.
- %The Hann function, time domain
- a=0.5; %Hann window specifics
- b=0.5;
- t=0:N-1; %Time axis
- w=a-b*cos(2*pi*t/(N-1)); %The function
- % plotting
- subplot(2,1,1)
- stem(t,w)
- xlabel('N')
- grid on
- %The Fourier Transformation, frequency domain
- v=0:1/(SEGMENTS-1):1; % Time axis with 1000 points
- W=fft(w,SEGMENTS); % Fourier transform with 1000 points
- Wabs=abs(W); % Take absolute value
- Wabs=mag2db(Wabs); % and convert to dB
- % plotting
- subplot(2,1,2)
- plot(v,Wabs);
- ylabel('dB')
- xlabel('Normalized frequency')
- grid on
- axis([0 1/2 -100 50])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement