find the 3 maximum elements and their index

hi everyone, i have a vector and i need to find the 3 maximum elements and their index, plz can anyone help me in that? thx

 채택된 답변

Srinivas
Srinivas 2012년 2월 29일

1 개 추천

help sort

추가 답변 (1개)

Jonathan Sullivan
Jonathan Sullivan 2012년 2월 29일

3 개 추천

r = rand(100,1);
[val ind] = sort(r,'descend');
val(1:3)
ind(1:3)
r(ind(1:3))

댓글 수: 2

amal
amal 2012년 2월 29일
thank u very much i tried it and it worked, but i forgot to mention that i need to do it with simulink :s
Srinivas
Srinivas 2012년 3월 1일
you can use the above written code in 'MATLAB Fucntion' block

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

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

질문:

2012년 2월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by