Sort() function return wrong values
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ernest Porqueras
am 15 Okt. 2020
Kommentiert: Ernest Porqueras
am 15 Okt. 2020
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/382193/image.png)
Anyone of you know how I can fix this problem?
Thanks
0 Kommentare
Akzeptierte Antwort
Stephen23
am 15 Okt. 2020
You are not assigning the sorted matrix to anything. You need to assign it to a variable, e.g.:
minCell = minCell(s, :);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!