how to split a cell array in to two ,each array carry same number of cells?

8 visualizaciones (últimos 30 días)
Iam having a cell array of size 214 *1,and each cell inside this has a size of 6*6,all the elements are numbers.Now I am in need of a code that helps me to split this cell array in to two each having a size of 107*1 and contain the equal number of elements in each cell.Then i need to access these individual cell arrays to give as an input to a CNN.Can anyone help me?

Respuestas (1)

Walter Roberson
Walter Roberson el 2 de Feb. de 2018
h = floor(size(TheCell,1)/2);
FirstArray = TheCell(1:h, :);
SecondArray = TheCell(h+1:end, :);
If you need random selection:
L = size(TheCell,1);
order = randperm(L);
h = floor(L/2);
FirstArray = TheCell(order(1:h), :);
SecondArray = TheCell(order(h+1:end), :);

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by