Borrar filtros
Borrar filtros

Find maximum peaks in fft and power spectral density function

12 visualizaciones (últimos 30 días)
marcusbarnet
marcusbarnet el 29 de Mzo. de 2018
Comentada: marcusbarnet el 29 de Mzo. de 2018
I have an array ( raw_acceleration) of 1600 elements acquired every 10 seconds at 160Hz from a sensor. I use this array to calculate the fft and the Power Spectral Density and it works very well:
Fs=160;
raw_acceleration = u;
N = length(raw_acceleration);
xdft = fft(raw_acceleration);
xdft = xdft(1:floor(N/2+1));
psdx = (1/(Fs*N)) * abs(xdft).^2;
psdx(2:end-1) = 2*psdx(2:end-1);
freq = 0:Fs/length(raw_acceleration):Fs/2;
plot(freq,10*log10(psdx))
grid on
xlabel('Frequency (Hz)')
ylabel('Power/Frequency (dB/Hz)')
I obtain this plot:
As you can see, I obtain four peaks centered around four different frequencies.
I would like to have a Matlab code which is able to automatically find these four maximum peaks and their frequency. At the moment, I always need to plot the graph and manually detect the maximum peak and its frequency.
Is there any way to do this by code? I hope you an help me.
I attached a sample of raw_acceleration array.

Respuestas (1)

Birdman
Birdman el 29 de Mzo. de 2018
  6 comentarios
marcusbarnet
marcusbarnet el 29 de Mzo. de 2018
I attach also the freq array
marcusbarnet
marcusbarnet el 29 de Mzo. de 2018
I tried to use max() function in Matlab, but I found out that it doesn't work as I would like..

Iniciar sesión para comentar.

Categorías

Más información sobre Parametric Spectral Estimation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by