필터 지우기
필터 지우기

Find maximum peaks in fft and power spectral density function

조회 수: 12 (최근 30일)
marcusbarnet
marcusbarnet 2018년 3월 29일
댓글: marcusbarnet 2018년 3월 29일
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.

답변 (1개)

Birdman
Birdman 2018년 3월 29일
  댓글 수: 6
marcusbarnet
marcusbarnet 2018년 3월 29일
I attach also the freq array
marcusbarnet
marcusbarnet 2018년 3월 29일
I tried to use max() function in Matlab, but I found out that it doesn't work as I would like..

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Parametric Spectral Estimation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by