필터 지우기
필터 지우기

Peaks of a function

조회 수: 2 (최근 30일)
Aaron Rosenberger
Aaron Rosenberger 2023년 5월 13일
답변: Star Strider 2023년 5월 13일
I need to calculate the frequenzy of a vibrating system.
i plotted the function and now to calculate the frequenzy i need the time between two peaks of the function.
just like:
x = max(function)
x2 = secondmax(function)
something like that ^^.
thank you very much for your help

답변 (2개)

Stephane
Stephane 2023년 5월 13일
편집: KALYAN ACHARJYA 2023년 5월 13일
There is a Matlab a function to detect peaks/local maxima: https://se.mathworks.com/help/signal/ref/findpeaks.html
You could also fit an exponentially decaying sinus if this is what you expect (https://se.mathworks.com/help/curvefit/fit.html) or do a Fourier analysis (https://se.mathworks.com/help/matlab/ref/fft.html).
  댓글 수: 2
Aaron Rosenberger
Aaron Rosenberger 2023년 5월 13일
Thank you very much ! :).
The "findpeaks" function works for me
KALYAN ACHARJYA
KALYAN ACHARJYA 2023년 5월 13일
You may accept the answer, if the answer helps to solve the issue.

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


Star Strider
Star Strider 2023년 5월 13일
This is relatively straightforward —
F1 = openfig('Plot.fig', 'visible');
Lines = findobj(F1, 'Type','Line');
t = Lines.XData.';
s = Lines.YData.';
Ts = mean(diff(t));
Fs = 1/Ts;
Fn = Fs/2;
L = numel(t);
NFFT = 2^nextpow2(L);
FTs = fft((s-mean(s)).*hann(L), NFFT)/L;
Fv = linspace(0, 1, NFFT/2+1)*Fn;
Iv = 1:numel(Fv);
[pks,locs] = findpeaks(abs(FTs(Iv))*2, 'MinPeakProminence',1E-7);
figure
plot(Fv, abs(FTs(Iv))*2)
grid
xlabel('Frequency (Hz)')
ylabel('Magnitude (m)')
title('Fourier Transform')
text(Fv(locs), pks, sprintf('\\leftarrow Magnitude %.3f\\times10^{-6} m\n Freq = %.3f Hz', pks/1E-6, Fv(locs)))
.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by