determine which cells have more than 1 row

조회 수: 3 (최근 30일)
Stephen Devlin
Stephen Devlin 2017년 7월 26일
답변: Stephen23 2017년 7월 26일
How can I find out the number of rows within a cell of a cell array
e.g. the cell array below, its first cell has 2 rows, I can't see online how to find out which rows have 2 etc
sectout =
8×1 cell array
[2×6 double]
[1×6 double]
[2×6 double]
[2×6 double]
[2×6 double]
[1×6 double]
[1×6 double]
[1×6 double]
Any ideas?

채택된 답변

Stephen23
Stephen23 2017년 7월 26일
cellfun('size',sectout,1)

추가 답변 (1개)

KSSV
KSSV 2017년 7월 26일
Run a loop and get the dimensions.
% make a random cell
K = cell(8,1) ;
for i = 1:8
K{i} = rand(randperm(10,1),randperm(10,1)) ;
end
%%Get number of rows
R = zeros(size(K)) ;
for i = 1:8
R(i) = size(K{i},1) ;
end
Or single line....below line gives dimensions of K...first column will be your rows..
R1 = cell2mat(cellfun(@size,K,'un',0)) ;

카테고리

Help CenterFile Exchange에서 Elementary Math에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by