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?
0 个评论
采纳的回答
更多回答(1 个)
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 Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!