Issues with understanding and interpreting single dimension FFT
8 次查看(过去 30 天)
显示 更早的评论
Greetings,
I am trying to get the FFT from a powermeter trace I acquired, but I seem to be doing it wrong and/or can't interpret the results.
My dataset is named Pm and has 720 points, separated by 10 seconds, for a total duration of 7200 seconds. I can provide the data vector if necessary, but it is just a simple vector.
Here are my questions.
- Why is the amplitude at 0Hz so high? I do not see this artefact in MATLAB's example of an FFT.
- Why is there an offset in the amplitude? I would expect the signal to hover around 0 in general.
- Based on visual inspection of the trace, I would expect a peak at around 0,0016Hz. I can see that there is a modulation of around 10 minutes in the trace.
Any help would be appreciated.
Here is the code I am using.
% This is to plot the data in units of time. I am using the following code from someone else to plot the moving average.
% The black curve is the moving average and the green points are the complete dataset.
figure
plot(Pm,'g.');
hold on;
plot(moving(Pm,7),'k');
legend('Pm','7pt moving mean')
xlabel('Temps / 10 (s)')
ylabel('P (mW)')
% This is the FFT part.
figure
Fs = 1/10; % Sampling frequency
T = 1/Fs; % Sampling period
L = length(Pm); % Length of signal
t = (0:L-1)*T; % Time vector
F = fft(Pm);
F2 = abs(F);
F3 = log(abs(F/length(Pm)));
P2 = abs(F/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs/L*(0:(L/2));
plot(f,P1);
xlabel("f (Hz)")
ylabel("|fft(Puissance)|")
figure
plot(Fs/L*(0:L-1),F3);
xlabel("f (Hz)")
ylabel("log[|fft(Puissance)|]")
% FFT plot
% Zoom in of the FFT plot
0 个评论
采纳的回答
Star Strider
2024-9-24
编辑:Star Strider
2024-9-24
It would help to have your data.
1 The 0 Hz value is high because that represents the mean of the time-domain signal. If you subtract the mean from the signal and then calculate the Fourier transform, the 0 Hz compionent goes to zero (or close to it). I do this routinely in order to avoid hiding the other peaks.
2. I’m not certain what you’re referring to.
3. I don’t have your signal. Subtracting the mean and then calculatting the Fourier transform could reveal the other ‘hidden’ peaks. Otherwise, witth a sampled siignal, the sampling introduces artifacts. These are less prominent at faster (higher) sampling frequencies, however essentially unavoidable. Also, windowing the signal could reveal more information, as could zero-padding it (using the length parameter) to increase the frequency resolution.
.
EDIT — (24 Sep 2024 at 18:31)
Note that the fft function assumes that the sampling intervals are regular and constant. If they aren’t, use the resample function to force them to be.
I usually use it as:
Fs = 1/mean(diff(t)); % Sampling Frequency, ‘t’ Is The Time Vector Corresponding To The Signal Samples
[sr,tr] = resample(s, t, Fs); % Return The Resampled Signal And Corresponding Time Vector
.
4 个评论
Star Strider
2024-9-24
My pleasure!
‘Is this therefore a standard procedure for signal processing?’
I am not certain that it is standard, although it is definitely recommended, for the reason I stated.
- No. In my ‘FFT1’ function, I use the hann window. The purpose of windowing is to correct for the fft being finite, instead of infinite as is the formal definition of the Fourier transform. Windowing produces a better and more representative spectrum result.
- That is one option. Here, I use the second argument to speciify the length of the fft. Making it a power-of-2 makes the fft calculation more efficient.
My pleasure!
.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!