How to choose the sampling frequency of a FFT based on my signal parameters ?
10 views (last 30 days)
Show older comments
I have a signal coming from an expermient, and I want to extract the frequencies from it. I made a simple method that extract the peaks and divide the number of the peaks by the duration of the whole signal, but I want to use the FFT method also.

I made the code and I have my FFT, but I don't know how to define the samplig frequency. I noticed that 100 Hz seems to be a good value but I don't want to choose it randomly, so my question is : is there any trick to determine the sampling frequency based on the signal parameters ?
I know there is the Nyquist theorem that says sampling frequency = 2x (max frequency-min frequency), but in this signal I don't really know what would be the min and the max.
For information here are the parameters of the signal I know :
- Duration
- Numer of points = 10 points/second
Here is a graph of the FFT with 100 Hz of sampling rate with the frequency dound with the simple peak method :

If I change the sampling frequency I see a shift betwen the two methods.
Here is my code if needed :
%FFT method
Fs = 100; % Sampling frequency
T = 1/Fs; % Sampling period
L = Length/10; % Length of signal in s
t = (0:L-1)*T; % Time vector
% x frequency
FFTx=fft(x,L);
P2 = abs(FFTx/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
figure('Name','Frequency spectrums');
tiledlayout(2,1);
nexttile;
hold on
plot(f,P1);
line([Peak_fx Peak_fx], [0 max(P1)],'Color','red');
hold off
legend('FFT method','Peak method');
The variable "Length" is the duration in 10th seconds, the variable "x" is the data from my signal and the "Peak_fx" variable is the frequency coming from the peak method.
3 Comments
Mathieu NOE
on 25 Feb 2021
this sounds a bit strange to me ... would you accept to share your data file ?
Answers (0)
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!