splitting a cell array and determining its size

2 vues (au cours des 30 derniers jours)
AA
AA le 20 Déc 2014
Commenté : Image Analyst le 20 Déc 2014
Imagine that you have a cell array and you want to determine its size. What command would you use for it? Also how do I split the data of the cell array into half. lets say it has 60 rows and and i want it to be split after 30 rows.
thanks

Réponse acceptée

Guillaume
Guillaume le 20 Déc 2014
Funnily enough. size is the function to get the size of cell arrays and matrices. If you want to split along rows, either use size or end:
c = num2cell(randi(200, 60, 5));
tophalf = c(1: ceil(end / 2), :); %equivalent to c(1 : ceil(size(c, 1) / 2), :)
bottomhalf = c(ceil(end / 2) + 1 : end, :);
  3 commentaires
Guillaume
Guillaume le 20 Déc 2014
To get the memory footprint of a variable it's whos
c = num2cell(randi(200, 60, 5));
msize = whos('c')
As for splitting:
tophalf = c(1:4, :);
bottomhalf = c(end-56+1:end, :);
Image Analyst
Image Analyst le 20 Déc 2014
That's a funny definition of "half".

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Cell 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