Hello, i need to sort this vector by value and also keep the position [109 97 116 108 97 98] to [5 1 6 4 2 3].
Any ideas how to do it?

 채택된 답변

Torsten
Torsten 2022년 11월 5일

1 개 추천

A = [109 97 116 108 97 98];
[~,p] = sort(A,'ascend');
r = 1:length(A);
r(p) = r
r = 1×6
5 1 6 4 2 3

추가 답변 (0개)

카테고리

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

태그

질문:

2022년 11월 5일

댓글:

2022년 11월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by