How to find dominant frequency of a vector?
6 views (last 30 days)
Show older comments
I have code I adapted from the fft documentation:
Fs = 960; % Sampling frequency
T = 1/Fs; % Sampling period
L = length(cpx3_filt); % Length of signal
Y=fft(cpx3_filt);
P2 = abs(Y/L);
P1 = P2(1:(L/2+1));
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
figure(2);
plot(f,P1)
title('Single-Sided Amplitude Spectrum of X(t)')
xlabel('f (Hz)')
ylabel('|P(f)|')
and I want to find the dominent frequency of my vector cpx3_filt (it holds center of pressure values) but for some reason this code is giving me a graph with the dominant frequency centered at zero. Can anyone help?
0 Comments
Answers (1)
Star Strider
on 24 May 2018
I have no idea what your signal looks like. The 0 Hz peak is the d-c (constant) offset. The easiest way to eliminate it is to take the fft of the signal after subtracting the mean of the signal:
Y=fft(cpx3_filt - mean(cpx3_filt));
That assumes ‘cpx3_filt’ is a vector, or a matrix where the individual signals are in each column.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!