f =
Could anyone explain the example provided in thr help for understanding the use of fft?
Ältere Kommentare anzeigen
I am trying to understand the using of fft in matlab, regarding the provided example in help I could not figure out what the f is and how it is defined as f = Fs*(0:(L/2))/L. Is there anybody who could explain why the f is defined as f = Fs*(0:(L/2))/L?
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
S = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
X = S + 2*randn(size(t));
plot(1000*t(1:50),X(1:50))
title('Signal Corrupted with Zero-Mean Random Noise')
xlabel('t (milliseconds)')
ylabel('X(t)')
Y = fft(X);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
plot(f,P1)
title('Single-Sided Amplitude Spectrum of X(t)')
xlabel('f (Hz)')
ylabel('|P1(f)|')
Akzeptierte Antwort
Weitere Antworten (1)
AH
am 18 Apr. 2024
0 Stimmen
When you take a L-point DFT of a signal
sampled at rate
, then the frequency interval
is uniformly sampled. The distance between two frequency points is
. Hnece, the discretized frequency is given by
. For a real-valued signal, it's sufficient to look at the positive side of the spectrum (a.k.a one-sided spectrum) as its Fourier transform symmetric with respect to frequency 0. Hence, the one sided frequency vector is
.
Hope this clarifies the main question.
Two caveats below are worth mentioning:
- How to deal with the right edge.
- In the code above, the spectrum of teh lowpass-equivalent (analytic signal) is shown.
For further detailed discussion on thistopic you may want to take a look at this example: Practical Introduction to Frequency-Domain Analysis
Kategorien
Mehr zu Spectral Measurements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!










