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

8 Ansichten (letzte 30 Tage)
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?

Antworten (1)

Walter Roberson
Walter Roberson am 2 Feb. 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), :);

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by