How can I use the returned sort index from the sort() function on a multidimensional array?
조회 수: 3 (최근 30일)
이전 댓글 표시
According to the documentation:
[B,I] = sort(___) also returns a collection of index vectors for any of the previous syntaxes. I is the same size as A and describes the arrangement of the elements of A into B along the sorted dimension. For example, if A is a vector, then B = A(I).
However, if A is not a vector, then B ~= A(I) since the sort index is returned as a collection of index vectors oriented along the same dimension that sort operates on rather than a linear index.
Is there a function to convert such a sort index into a linear index array, say f(I), such that B = A(f(I)), where f(x) would be similar in theory to sub2index() with the other dimensions inferred from the size of the sort index?
댓글 수: 0
참고 항목
카테고리
Help Center 및 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!