How to find the index of the first minimum element

조회 수: 6 (최근 30일)
Chamira Wickramasinghe
Chamira Wickramasinghe 2015년 3월 19일
답변: Sean de Wolski 2015년 3월 19일
Hello,
I have a 1X6 matrix.
y = [682.8333 399.8160 34.2270 46.1800 107.7035 ];
I wanna find the first minimum element (not the minimum value the first minimum value which means the first value that has two greater values on left and right sides) (the first negative peak)
In here it must be 34.2270 ( I know it can be found by "out = y(find(diff(y)>0,1,'first'));" )
And I wanna know what the index of that element.
In here it must be 3.
Thank you.

답변 (1개)

Sean de Wolski
Sean de Wolski 2015년 3월 19일
[~,idx] = min(y)

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by