Finding several peaks in a vector
13 次查看(过去 30 天)
显示 更早的评论
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.
3 个评论
Will Reeves
2023-2-17
编辑:Will Reeves
2023-2-17
"islocalmax" sure, "findpeaks"? it's in the signal processing toolbox...
I can't justify to my company the ongoing price of an entire toolbox for a single function. (As a warning, I believe Mathworks need to start rolling in some of the basic functionality into base Matlab. I'm constantly being pulled in the direction of python by my colleagues, I'm not a fan really, but at some point they're going to win)
Generic data exploration tools really should be included with Matlab.
Star Strider
2023-2-17
@Will Reeves — See the What is missing from MATLAB #2 - the next decade edition thread and discuss it there.
Your concerns may already have been mentioned. (I don’t follow that thread closely.)
回答(1 个)
Sai Veeramachaneni
2020-12-15
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!