Seems like a bug in Matlab R2015a "sort" routine
이전 댓글 표시
a =[24 9 27 14; 1 40 9 33; 17 16 31 35];
[aSort, iSort] = sort(a, 2, 'descend');
% Those should be exactly the same
isequal(a(iSort), aSort)
But they are not!
Lets see what do we have:
aSort =
27 24 14 9
40 33 9 1
35 31 17 16
iSort =
3 1 4 2
2 4 3 1
4 3 1 2
Apparently iSort is totally messed up! It is not global indexing as it should be!!! It should span 1:numel(a), but instead is spans 1:size(a, 2)- only indexes along sorted dimension! Seems like a severe bug to me. One has to play with "ind2sub" and "sub2ind" to get it right...
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 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!