Sort() function return wrong values
조회 수: 5 (최근 30일)
이전 댓글 표시
I have used this code to sort a 342x2 matrix using the second column as a reference to mantain the correspondence between rows:
[~, s] = sort(minCell(:,2));
minCell(s, :);
The problem is that the result is not correct. Second column has values between 1 and 9000 and it seems it doesn't work well with numbers <100

Anyone of you know how I can fix this problem?
Thanks
댓글 수: 0
채택된 답변
Stephen23
2020년 10월 15일
You are not assigning the sorted matrix to anything. You need to assign it to a variable, e.g.:
minCell = minCell(s, :);
추가 답변 (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!