What is different between FFT and SHIFTFFT
25 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
University
am 30 Okt. 2023
Kommentiert: University
am 2 Nov. 2023
Please can someone explain why this code :
fftshift(fft((x - mean(x)).*hann(L), NFFT)/sum(hann(L)))
is better than
fftshift(fft(x))?
Why not fftshift(fft(x))?
Why subtracting mean(x) from fftshift(fft(x))?
From matlab documentation Hann returns an L-point symmetric Hann window. Please does this mean?
Why sum(hann(L)) ? Why not hann(L)?
2 Kommentare
Walter Roberson
am 30 Okt. 2023
Subtracting the mean gets you an fft() in which the first bin is 0 . But it is not clear that is productive since hann() starts with a 0.
sum(hann(L)) appears to be (L-1)/2 for L > 2 -- for L = 2 exactly the "0 at the end" rule takes precidence. For L = 1 exactly hann() is 1 .
Akzeptierte Antwort
Chunru
am 31 Okt. 2023
First, it is not correct to say which is better unless you define what is "better". fft(x) has better resolution but higher sidelobe levels than fft(x.*hann(L)).
The substraction of mean(x) from x is to remove the DC component so that the spectrum has 0 (approximately) at 0 frequency.
fftshift is to re-arrange the frequency axis. fft alone has frequency from 0-fs. fftshift has frequency range of (-fs/2, fs/2).
Division by sum(hann(L)) is a normalization factor. With this normalization a unit amplitude signal exp(2i*pi*f) will have a unit spectrum value:
f0 = 1/4;
L = 512;
w = hann(L);
x = exp(2i*pi*f0*(0:L-1)'); % unit amplitude
y = fft(x.*w./sum(w)); % unit spectrum at f0
plot(abs(y))
To recap:
Why not fftshift(fft(x))? ==> You can use it if you don't mind the side lobe level.
Why subtracting mean(x) from fftshift(fft(x))? ==> To remove DC from the signal and spectrum.
From matlab documentation Hann returns an L-point symmetric Hann window. ==> Normalization factor
3 Kommentare
Chunru
am 31 Okt. 2023
Bearbeitet: Chunru
am 31 Okt. 2023
It seems there is a confusion here. Even the hanning window has 0 for t=0 (assuming L>>1). Multiply x(t) with h(t) will make a modified signal s(t)=x(t)*w(t) and s(t=0)=0. But this will not make F(f=0)=0 in general.
However, subtracting mean, i.e. x(t)-mean(x) will ensure its Fourier Transform has 0 (up to round-off error) amplitude for DC (ie first bin). So it DOES matter to substract mean if one wants to remove DC, whether h(0)=0 or not. See the illustration below (paying attention to DC component).
==> combination fft(x) .* hann(L) then the result is going to be the same (to within round-off error) as fft(x-mean(x)) .* hann(L)
Note that we are concerned with time domain window, x.*h, instead of frequency domain window fft(x).*h.
fftshift(fft( (x - mean(x)) .*hann(L), NFFT)/sum(hann(L)))
The above is a time domain window instead of freq domain window.
f0 = 1/4;
L = 512;
w = hann(L);
x = exp(2i*pi*f0*(0:L-1)') + 1; % unit amplitude
y = fft(x.*w./sum(w)); % unit spectrum at f0
subplot(121)
plot(abs(y)); title('With DC')
y1= fft((x-mean(x)).*w./sum(w));
subplot(122)
plot(abs(y1)); title('DC Removed')
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Transforms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!