how to split a cell array in to two ,each array carry same number of cells?
8 views (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
Walter Roberson
on 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), :);
0 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!