For example we have a row like
m=[1 6 2 8 9] [Y,I] = sort(m)
then it gives you
Y =
1 2 6 8 9
I =
1 3 2 4 5
But I would like to sort them from big number to small

 채택된 답변

Joan Puig
Joan Puig 2011년 9월 10일

3 개 추천

Hi,
There is an extra optional argument that will do that:
>> m=[1 6 2 8 9]; [Y,I] = sort(m,'descend')
Y =
9 8 6 2 1
I =
5 4 2 3 1
>>

댓글 수: 1

Saurabh saini
Saurabh saini 2021년 10월 18일
thanks for your answer it is very helpful to save time sir

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

추가 답변 (1개)

Wayne King
Wayne King 2011년 9월 10일

0 개 추천

Hi, have you read the documentation for sort()?
m = [1 6 2 8 9];
[Y,I] = sort(m,'descend');
Wayne

카테고리

도움말 센터File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

질문:

2011년 9월 10일

댓글:

2021년 10월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by