필터 지우기
필터 지우기

How do I get a maximum and minimum for a singular wave while ignoring the other local maximums and minimums?

조회 수: 2 (최근 30일)
I have wave data from a buoy and am trying to identify the overall crest and trough amplitude for 50 individual waves. However, when using islocalmax/min it identifies all the locals and not the highest absolute value. I tried using minprominence but the amount of data points for each crest and trough is inconsistent. The section of code I'm using is below(original data file is .dat extension so I converted to .txt to upload here).
filedata=load('waves_n_130.dat');
A= filedata(:,4);
for n=1:8191
wmin=islocalmin(A,'MinProminence',0);
wmax=islocalmax(A,'MinProminence',0);
end

채택된 답변

Star Strider
Star Strider 2022년 10월 10일
LvPks = islocalmax(y, 'MinProminence',0.01, 'MinSeparation',45); % 'islocalmax'
plocs = find(LvPks);
pks = y(plocs);
[maxpk,ploc] = max(pks)
This returned:
maxpk = 0.2899
ploc = 79
and:
[mintr,tloc] = min(trs)
returned:
mintr = -0.3222
tloc = 77
And this:
Pk_Tr_Amp = pks(1:end-1)-trs;
[maxamp,loc] = max(Pk_Tr_Amp)
returned:
maxamp = 0.5668
loc = 77
Just add those lines (and perhaps others) to my code to get the results you want.
NOTE — There is one more peak than trough, and the vector lengths must be equal in order to compare them.
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by