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
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Axis Labels에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!