Borrar filtros
Borrar filtros

How can I sort data in increasing order

5 visualizaciones (últimos 30 días)
JAKE WISNIEWSKI
JAKE WISNIEWSKI el 24 de Sept. de 2021
Comentada: Image Analyst el 27 de Sept. de 2021
I have been given this data
I want to classify the length in each row as either the shortest(S), longest(L), or other (P or Q) so i can use this equation S+L=P+Q
Here is my code so far.
  3 comentarios
JAKE WISNIEWSKI
JAKE WISNIEWSKI el 26 de Sept. de 2021
Thank you for the input. I will be sure to do this in the future.
Image Analyst
Image Analyst el 27 de Sept. de 2021
@JAKE WISNIEWSKI, Why can't you do it now? All I can suggest is to use sort() or sortrows(). And I'm not sure I buy this equation
S+L=P+Q
What makes you think it will be true? For example for one row where the L's are [6,2,7,9] you have
2 + 9 = 6 + 7
or
11 = 13
which is obviously not true.

Iniciar sesión para comentar.

Respuestas (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 24 de Sept. de 2021
Use sort() that sorts in an ascending order and then take the indexes that will be used for the others, OR put in a table using array2table() and sort them in order.

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by