Finding minima in data as well as values near it

1 回表示 (過去 30 日間)
Elijah L
Elijah L 2020 年 9 月 16 日
編集済み: Ameer Hamza 2020 年 9 月 16 日
I have a column of data (zpoint) and I need to find all the minima (valleys) in the data.
For every minima, need to find the previous data point and the next data point using a 'for' loop and 'if' constructs.
For example, if the data is
17
12
3
15
46
I need the script to find the 12 and 15

回答 (2 件)

KSSV
KSSV 2020 年 9 月 16 日
Read about min. Let A be your array.
[val,idx] = min(A) ;
iwant = [A(idx-1) A(idx+1)]

Ameer Hamza
Ameer Hamza 2020 年 9 月 16 日
編集済み: Ameer Hamza 2020 年 9 月 16 日
This will find all the local minima and the points around it.
x = [17 12 3 15 46];
idx = islocalmin(x);
idx = idx | circshift(idx, 1) | circshift(idx, -1);
values = x(idx);
Result
>> values
values =
12 3 15

カテゴリ

Help Center および File ExchangeSmoothing and Denoising についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by