Sort() function return wrong values

5 vues (au cours des 30 derniers jours)
Ernest Porqueras
Ernest Porqueras le 15 Oct 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
Anyone of you know how I can fix this problem?
Thanks

Réponse acceptée

Stephen23
Stephen23 le 15 Oct 2020
You are not assigning the sorted matrix to anything. You need to assign it to a variable, e.g.:
minCell = minCell(s, :);
  1 commentaire
Ernest Porqueras
Ernest Porqueras le 15 Oct 2020
You are right! Thank you

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by