필터 지우기
필터 지우기

Of Cell Arrays & Sort

조회 수: 1 (최근 30일)
RDG
RDG 2012년 9월 6일
Greetings,
for i=1:5
x{i}=i
end
for j=1:7
y{j}=j
end
merge_twocell = [x y]
Now say I have a variable, select_var and I want to select the lowest 3 values from x and 4 lowest values from y, how can I achieve this?
P/S I'm avoiding using cell2mat, sort the elements, then retrieve what I want. Is there a more direct approach?

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 6일
편집: Azzi Abdelmalek 2012년 9월 6일
x1=sortrows(x);y1=sortrows(y);
x_min=x1(1:3)
y_min=y1(1:4)
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 6일
편집: Azzi Abdelmalek 2012년 9월 6일
I did'nt see it was a cell, Now I use sortrows instead of sort
x1=sortrows(x);y1=sortrows(y);
x_min=x1(1:3)
y_min=y1(1:4)
RDG
RDG 2012년 9월 6일
Oh, yes yes. Sorry. Thank you very much!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by