how to find max and min value within a certain range of a plot

Hi, I'm using plot function to identify second wave and measure it's frequency, so is there any way for me to get timeseries of the max and min value within the second wave range directly without have to search them in csv files. Thank you.

2 Comments

This is the plot file and want to know how to find the timeseries of first upper peak and second lower peak.

Sign in to comment.

 Accepted Answer

Use the bounds function on the specific plot argument.

3 Comments

EDIT — (13 Apr 2023 at 17:34)
I am not certain what you want. This provides the peak values, locations, and frequencies of each peak, valley, and complete wave. (The frequencies are not printed on the plot because there is not room enough for them.)
I = openfig('tek0000ALL.fig');
grid
Lines = findobj(I, 'Type','line');
xv = Lines.XData;
yv = Lines.YData;
Tss = [mean(diff(xv)) std(diff(xv)) median(yv)];
Fs = 1/Tss(1);
[pks,plocs] = findpeaks(yv, 'MinPeakProminence',max(yv)/4);
[vys,vlocs] = findpeaks(-yv, 'MinPeakProminence',max(-yv)/4);
zxix = find(diff(sign(yv-median(yv))));
rtbl = find(zxix>max(vlocs),1,'first');
zxix = zxix(1:rtbl);
periodv = diff(xv(zxix));
pervbfr = buffer(periodv,2);
freqv = 1./sum(pervbfr) % Frequency Of Each Complete Wave
freqv = 1×4
1.0e+06 * 0.8039 2.8090 1.2136 0.5869
figure
plot(xv, yv)
hold on
hold off
grid
yline(median(yv))
text(xv(plocs), pks, compose(['(%.2fx10^{-5}, %.3f)'],[xv(plocs)*1E5; pks].') )
text(xv(vlocs), -vys, compose(['(%.2fx10^{-5}, %.3f)'],[xv(vlocs)*1E5; -vys].') )
.

Sign in to comment.

More Answers (0)

Categories

Asked:

on 12 Apr 2023

Commented:

on 13 Apr 2023

Community Treasure Hunt

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

Start Hunting!