FFT from CSV file
11 次查看(过去 30 天)
显示 更早的评论
I'm trying to perform FFT on the 2nd data column of a .csv file. The .csv file is quite large and the zipped version can be found here: https://www.dropbox.com/s/87l5vtxdqfbtt6x/Tridral_1m_1ms.7z?dl=0
The signal is 10 milliseconds long, and is sampled 1 million times over that time period. I've tried following the FFT example provided by the help file, but the frequency domain signal does not come out right. The FFT output gives a strong DC signal (that could be right), and a signal at 50 KHz. Based on the time domain signal, i should expect approximately a 1 KHz fundamental with recurrent harmonics at 2, 3, 4 KHz..., but it comes out empty... am i doing something wrong in my code?
0 个评论
采纳的回答
dpb
2019-2-16
Follow the recipe provided precisely...you've doubled the DC and Fmax components so that the DC bias is shown as twice what it would really be--and to find the frequency content in the signal you should either remove the mean first or, alternatively, just zero-out the DC component of the PSD. The former will be better numerically in preventing loss of precision in low-energy bins in the FFT, so that would be my recommendation.
...
y=raw_data(:,2)-mean(raw_data(:,2)); % eliminate DC bias
L=length(y);
Y = fft(y); % with 1E6 points, don't need interpolating
P2 = abs(Y/L); % two-sided spectrum
P1 = P2(1:L/2+1); % one-sided
P1(2:end-1) = 2*P1(2:end-1); % normalize; except not DC and Fmax that are only one point
f = Fs*(0:(L/2))/L;
plot(f,P1) % should show you actual frequency content
Undoubtedly, using semilogy() to amplify the dynamic range and zooming in on the lower frequency range will help to be able to see what structure there is in the signal.
You'll need to ensure the input signal is actually quality data and not contaminated somehow, too, of course...
4 个评论
dpb
2019-2-19
Yeah, I whiffed on that first go 'round; just took the Fs at face value without really looking at the rest that carefully...
Illustrates that the FFT doesn't care a whit about what the actual sample rate is; it just computes the numbers by bin; it's totally up to the user to set the scaling of the frequency axis to match the actual data collection process.
更多回答(1 个)
Sofi Fatoni putra
2019-10-2
编辑:Sofi Fatoni putra
2019-10-2
if I can ask for your data once again because the download in your dropbox can't be downloaded
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Transforms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!