FFT - Matlab Code not correct

3 ビュー (過去 30 日間)
Mepe
Mepe 2018 年 7 月 9 日
編集済み: dpb 2018 年 7 月 9 日
Hello,
By means of ultrasonic sensors I made some measurements and would like to evaluate them now via Matlab (data source "data_time_domain.csv". I used 5MHz sensors and also set this frequency as input to the Pulse Generator. The automatically performed FFT on the oscilloscope also shows a peak at 5MHz as expected (oscilloscope_original_frequency_plot.jpg).
Now I try to use the data from the time-domain to perform the FFT in Matlab shows another picture (Matlab_frequency_plot.jpg). Here, the peak is at a much lower frequency. There is no explanation but surely the error will be in my code. As a sampling frequency, I have chosen the frequency that I have also set the pulse generator (5Mhz).
Do you have any idea where the mistake lies?
Many thanks! Regards, Frank
L=2424; %length of the signal
Fs=5000000; %sampling frequency
Fn=Fs/2 % Nyquistfrequenz
N=2^nextpow2(L); %scale factor
t=(0:L-1)*10^-3; %time domain array
f=linspace(0,Fn,length(t)); %frequency domain array
figure(1)
grid on
plot(t(1:length(t)),ChannelA(1:length(t)),'b') %plotting of the time domain)
title('Time Domain')
xlabel('time [s]')
ylabel('amplitude [V]')
%%FAST FOURIER TRANSFORM
xFFT=abs(fft(ChannelB,N)/L); % Divide By ‘L’ To Scale For Signal Vector Length
figure(2)
grid on
plot(f,xFFT(1:2424)*2,'b'),title('Frequency Response') %plotting the frequency spectrum (half spectrum->double amplitude)
xlabel('Frequency [Hz]')
ylabel('amplitude [V]')

回答 (1 件)

dpb
dpb 2018 年 7 月 9 日
編集済み: dpb 2018 年 7 月 9 日
"As a sampling frequency, I have chosen the frequency that I have also set the pulse generator (5Mhz)."
There's your problem; you must sample at least twice the highest frequency in the signal (look up "Nyquist frequency").
Commercial O-scopes sample at much higher multiples than that in their auto modes; the Fmax of the plot you show is 10 MHz; if the scope uses only a simple baseband FFT, then you can presume a sample rate of 20 MHz.
You should be able to also download the sampling parameters from the scope to confirm the settings besides just the time trace values; see the doc for the instrument for how...
Also there's some inconsistency in the frequency vector and normalization; the Matlab FFT is two-sided in frequency; see the example in
doc fft
to see the generic way to pick the positive frequency and to normalize the one-sided PSD as there is only a single DC and Fmax array element.

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by