Is there a built in function like MinPeakHeight but for maximum numbers?

5 views (last 30 days)
It would be something like MaxPeakHeight to find negative peaks. I have a random signal with positive and negative values and need to find negative peaks.

Answers (3)

Walter Roberson
Walter Roberson on 18 Mar 2022
Work with the negative of the signal; the most negative original signal would become the most positive on the transformed signal.
  1 Comment
Heirleking on 18 Mar 2022
That would be true if all the positive vales were the same as the negative… not in my case, tho

Sign in to comment.

Image Analyst
Image Analyst on 18 Mar 2022
Walter is right. You just didn't understand. Here is some code to explain it. You can do
% Find peaks.
[peakValues, indexesOfPeaks] = findpeaks(signal); % Add options if you want.
% Find valleys. They will be peaks of the inverted signal.
[valleyValues, indexesOfValleys] = findpeaks(-signal); % Add options if you want.
% Now invert the values to make them upside down again.
valleyValues = -valleyValues;
Note it doesn't matter if your signal is all positive, all negative, or even crosses the y=0 axis so that it has both positive and negative values. The code above will work. There are some options (granted most of them are confusing) that can help you narrow down the peaks and valleys to just the ones you want.

Sign in to comment.

Star Strider
Star Strider on 18 Mar 2022
Another option is the islocalmin function (introduced in R2017b).

Community Treasure Hunt

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

Start Hunting!