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?

 Akzeptierte Antwort

Jan
Jan am 21 Jan. 2013

0 Stimmen

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

3 Kommentare

baby
baby am 21 Jan. 2013
do u know how to choose the 3 first lowest number in that cell after it sorted?
Jan
Jan am 21 Jan. 2013
sorted_f(end-2:end, :)
baby
baby am 21 Jan. 2013
Bearbeitet: baby am 21 Jan. 2013
thx u so much :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Thorsten
Thorsten am 21 Jan. 2013
Bearbeitet: Thorsten am 21 Jan. 2013

0 Stimmen

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

4 Kommentare

baby
baby am 21 Jan. 2013
Thorsten, how to choose the 3 first lowest number in that cell after it sorted?
Thorsten
Thorsten am 21 Jan. 2013
low3 = [f(end-2:end, 1)];
baby
baby am 21 Jan. 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 am 3 Okt. 2021
nLow=3;
[f, ind] = sort([f{:, 1}]);
fLow = f(1:nLow, :)

Melden Sie sich an, um zu kommentieren.

Kategorien

Tags

Gefragt:

am 21 Jan. 2013

Kommentiert:

dpb
am 3 Okt. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by