필터 지우기
필터 지우기

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
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일
[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