how to Sorting a cell?

4 visualizaciones (últimos 30 días)
baby
baby el 21 de En. de 2013
Comentada: dpb el 3 de Oct. de 2021
hello all,,
i want to ask u about how to sorting a cell which element is combination number and string
example
f =
[16] 'good'
[25] 'good'
[ 9] 'bad'
[13] 'bad'
i wanna sorting that cell by minimum value
how to make it?

Respuesta aceptada

Jan
Jan el 21 de En. de 2013
[dummy, index] = sort([f{:, 1}]);
sorted_f = f(index, :);
  3 comentarios
Jan
Jan el 21 de En. de 2013
sorted_f(end-2:end, :)
baby
baby el 21 de En. de 2013
Editada: baby el 21 de En. de 2013
thx u so much :)

Iniciar sesión para comentar.

Más respuestas (1)

Thorsten
Thorsten el 21 de En. de 2013
Editada: Thorsten el 21 de En. de 2013
[sorted ind] = sort([f{:, 1}]);
f = f(ind, :)
  4 comentarios
baby
baby el 21 de En. de 2013
it just give one result like this
[9]
[13]
[16]
i want the result like this
[9] 'bad'
[13] 'bad'
[16] 'good'
how to make like that?
dpb
dpb el 3 de Oct. de 2021
nLow=3;
[f, ind] = sort([f{:, 1}]);
fLow = f(1:nLow, :)

Iniciar sesión para comentar.

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