how to Sorting a cell?

1 次查看(过去 30 天)
baby
baby 2013-1-21
评论: dpb 2021-10-3
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?

采纳的回答

Jan
Jan 2013-1-21
[dummy, index] = sort([f{:, 1}]);
sorted_f = f(index, :);
  3 个评论
baby
baby 2013-1-21
编辑:baby 2013-1-21
thx u so much :)

请先登录,再进行评论。

更多回答(1 个)

Thorsten
Thorsten 2013-1-21
编辑:Thorsten 2013-1-21
[sorted ind] = sort([f{:, 1}]);
f = f(ind, :)
  4 个评论
baby
baby 2013-1-21
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 2021-10-3
nLow=3;
[f, ind] = sort([f{:, 1}]);
fLow = f(1:nLow, :)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by