Hanning window and online FFT

fft, matlab, signal-processing

Solution

I hope the following piece of code is helpful to you.

L = 10;
win1 = hanning(L);
win2 = triang(L);
nfft = 64;
S1 = fft(win1,nfft);
S2 = fft(win2,nfft);
f = 1:nfft/2+1;
plot(f,10*log10(abs(S1(1:nfft/2+1))),'.-',f,10*log10(abs(S2(1:nfft/2+1))),'o-');

Annotation:

You can put `win1` and `win2` as Time-series signal. `L` is the length of `win1` or `win2`. `nfft` is the length of FFT . if `L < nfft` , then the function `fft()` will add `0` to the rest of `nfft`. If `L > nfft`, then the function `fft()` will interception the length of `L` to equal `nfft`.

Problem

I am learning DSP and I couldn't write a code to calculate and plot these figures (just magnitude of Hanning and triangular windows in frequency domain.) Could anyone please help me with the code? I've read something related to online FFT, and, for example, they calculate online FFT with 1024 time steps. I don't understand what is 1024 time steps, and what are the influences of time step value to FFT analysis?

Original source