MATLAB Answers

Finding several peaks in a vector

1 view (last 30 days)
maytal melchior
maytal melchior on 12 Dec 2020
Answered: Sai Veeramachaneni on 15 Dec 2020
I want to write a code that takes a vector and finds the number of "peaks", maximums or minimums, when there are several peaks.
The vector could be a different range everytime.
Also, if possible, I would like the output to give me the location in the vector.
  1 Comment
Star Strider
Star Strider on 12 Dec 2020
Why not just use findpeaks or islocalmax?

Sign in to comment.

Answers (1)

Sai Veeramachaneni
Sai Veeramachaneni on 15 Dec 2020
Hi,
You can use islocalmax and islocalmin functions to calculate locations of local maximums and minimums respectively.
You can use sum function over islocalmax and islocalmin to count number of peaks in the given vector.

Community Treasure Hunt

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

Start Hunting!