Of Cell Arrays & Sort
조회 수: 1 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
채택된 답변
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
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)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!