FFT from CSV file

조회 수: 14 (최근 30일)
Ray Fang
Ray Fang 2019년 2월 16일
편집: Sofi Fatoni putra 2019년 10월 2일
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?

채택된 답변

dpb
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
Ray Fang
Ray Fang 2019년 2월 19일
Thanks. It makes sense now that the sampling rate is 1E6 samples/10ms = 100 MHz. I'm getting the fundamental at 1,KHz and harmonics at 2, 3..., KHz, which looks correct.
dpb
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
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

카테고리

Help CenterFile Exchange에서 Transforms에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by