how to find array of second minimum value based on the index value

조회 수: 1 (최근 30일)
Manjutha Manavalan
Manjutha Manavalan 2016년 5월 6일
댓글: Azzi Abdelmalek 2016년 5월 6일
index=[1 2 3 4 5];
p(i)=[0.1 0.2 0. 3 0.4 0.5];
based on the random position of p(i) second minimum value should occur not the index value
  댓글 수: 1
Azzi Abdelmalek
Azzi Abdelmalek 2016년 5월 6일
What random position? "second minimum value should occur": what does that mean?

댓글을 달려면 로그인하십시오.

답변 (1개)

Weird Rando
Weird Rando 2016년 5월 6일
편집: Weird Rando 2016년 5월 6일
Unique function returns the vector in ascending order discarding any repetitive values. And the find function returns the index value.
p =[0.1 0.2 0.2 0.4 0.5];
a = unique(p);
find(p == a(2), 1,'first')
You can also find all the index value of the 2nd minimum value by replacing the find with
find(p == a(2))

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by