How do I construct the dft response of hanning window
Show older comments
Hi,
I am trying to do an fft of the Hanning window function.
Below is the code that I have implemented:
N=input("Enter the number of samples = ");
T=input("Enter the time sampling = ");
n=0:T:N;
wn=0.5*(1-(cos(2*pi*n/N)));
figure(1);
subplot(2,1,1);
plot(n,wn);
%fft of hann window
wf=fft(wn,N);
fshift = linspace(-length(wf)/2,(length(wf)-1)/2,length(wf));
subplot(2,1,2);
plot(fshift, fftshift(abs(wf)));
disp("The length of wn "+length(wn)+" Length of wf "+length(wf));
%Creating hanning function with hann function
figure(2);
fn=hann(N);
subplot(2,1,1);
plot(fn);
fk=fft(fn);
subplot(2,1,2);
plot(fftshift(abs(fk)));
The plots that I am getting are: 

and

I wanted to know why the fft is not generating the side lobes of the Hanning window that we are generally accustomed to seeing?
Accepted Answer
More Answers (0)
Categories
Find more on Digital Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
