필터 지우기
필터 지우기

How to find the index of top k max values in the matrix

조회 수: 15 (최근 30일)
Hang Vu
Hang Vu 2019년 7월 24일
댓글: Hang Vu 2019년 7월 24일
A=[ 5 40 10 9 2 1 8 12 33 23]
find index of top 3 max values as:B= [ 2 9 10]
and return the rest index value in another array C=[1 3 4 5 6 7 8]
Thank you.

채택된 답변

Bruno Luong
Bruno Luong 2019년 7월 24일
>> A=[ 5 40 10 9 2 1 8 12 33 23]
A =
5 40 10 9 2 1 8 12 33 23
>> [~,B]=maxk(A,3)
B =
2 9 10
>> C=setdiff(1:length(A),B)
C =
1 3 4 5 6 7 8
  댓글 수: 10
madhan ravi
madhan ravi 2019년 7월 24일
Alright , thank you :)
Hang Vu
Hang Vu 2019년 7월 24일
Thank you so much for the help! and your time also.

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

추가 답변 (1개)

madhan ravi
madhan ravi 2019년 7월 24일
편집: madhan ravi 2019년 7월 24일
[~,idx]=sort(A,'descend');
B=idx(1:3)
C=setdiff(idx,B)

카테고리

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