How to sort values and strings

9 visualizaciones (últimos 30 días)
Leon
Leon el 6 de Nov. de 2013
Comentada: Leon el 6 de Nov. de 2013
I have a data set with several variables, their sizes are all (10000, 1), i.e., 10000 rows and 1 column.
Stations are strings, but depths and other variables are numerical values. I want to sort all of them according to depth. How should I achieve this?
Thank you

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 6 de Nov. de 2013
Editada: Azzi Abdelmalek el 6 de Nov. de 2013
Stations={'a';'b';'c'}
depth=[1;3;2]
height=[3;1;2]
v=[Stations num2cell([depth height])]
sortrows(v,2) % depth is in the second column
  1 comentario
Leon
Leon el 6 de Nov. de 2013
Thank you so much, Azzi! It works.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by