determine which cells have more than 1 row

3 次查看(过去 30 天)
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 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by