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 日

0 投票

[dummy, index] = sort([f{:, 1}]);
sorted_f = f(index, :);

3 件のコメント

baby
baby 2013 年 1 月 21 日
do u know how to choose the 3 first lowest number in that cell after it sorted?
Jan
Jan 2013 年 1 月 21 日
sorted_f(end-2:end, :)
baby
baby 2013 年 1 月 21 日
編集済み: baby 2013 年 1 月 21 日
thx u so much :)

サインインしてコメントする。

その他の回答 (1 件)

Thorsten
Thorsten 2013 年 1 月 21 日
編集済み: Thorsten 2013 年 1 月 21 日

0 投票

[sorted ind] = sort([f{:, 1}]);
f = f(ind, :)

4 件のコメント

baby
baby 2013 年 1 月 21 日
Thorsten, how to choose the 3 first lowest number in that cell after it sorted?
Thorsten
Thorsten 2013 年 1 月 21 日
low3 = [f(end-2:end, 1)];
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, :)

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

質問済み:

2013 年 1 月 21 日

コメント済み:

dpb
2021 年 10 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by