Retrun largest numbers?

조회 수: 1 (최근 30일)
htet wai
htet wai 2018년 5월 10일
댓글: htet wai 2018년 5월 10일
Can you help me how to retrun the larget numbers from the array as in the same order of that array?
for example i have A = 8 , 3, 4 , 1 , 5 , 6 , 2 , 7 , 9. I want to return largest 3 number in the same order as A like that B = 8 , 7 , 9.

채택된 답변

ES
ES 2018년 5월 10일
편집: ES 2018년 5월 10일
>> [~, idx] = sort(A);
>> B = A(sort(idx(end-2:end))))
  댓글 수: 1
htet wai
htet wai 2018년 5월 10일
Thank you for your help.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by