max and min in one cycle
Show older comments
Hi everyone
I have a signal, I need to find max and min values for each cycle in this signal.
Let's say we have the signal A which has two cycles:
Signal=[0 -2 -3 -3.5 -3.25 -2.5 -1.75 -1 0 1 1.8 2.6 3.25 3.5 3.25 2.6 1.7 0 -2 -3 -3.5 -3.25 -2.5 -1.75 -1 0 1 1.8 2.6 3.25 3.5 3.25 2.6 1.7 0]
as shown in the attached picture.

I should get for the first cycle -3.5 and 3.25 and the same values for the second cycles.
Thank you in advance
2 Comments
Walter Roberson
on 16 May 2018
Perhaps run findpeaks twice, once on Signal and once on -Signal
Mohanned Al Gharawi
on 16 May 2018
Accepted Answer
More Answers (1)
Walter Roberson
on 16 May 2018
[maxpk, maxloc] = findpeaks(Signal);
[minpk, minloc] = findpeaks(-Signal);
extremevals = [maxpk.', -minpk.'];
extremlocs = [maxloc.', minloc.'];
>> extremevals
extremevals =
3.5 -3.5
3.5 -3.5
>> extremlocs
extremlocs =
14 4
31 21
1 Comment
Mohanned Al Gharawi
on 16 May 2018
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!