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