How do I sort an array in descending order without using the sort function?
이전 댓글 표시
A = [2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19]
채택된 답변
추가 답변 (2개)
Walter Roberson
2015년 11월 5일
flipud(unique(A(:)))
Here are a few ways to sort an array of unique values without using sort:
sortrows(A(:),-1)
A(end:-1:1) = unique(A);
fliplr(union(A,A(1)))
fliplr(setdiff(A,NaN))
카테고리
도움말 센터 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!