determine which cells have more than 1 row

3 vues (au cours des 30 derniers jours)
Stephen Devlin
Stephen Devlin le 26 Juil 2017
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?

Réponse acceptée

Stephen23
Stephen23 le 26 Juil 2017
cellfun('size',sectout,1)

Plus de réponses (1)

KSSV
KSSV le 26 Juil 2017
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)) ;

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by