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 Exchange에서 Shifting 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