how to split a cell array in to two ,each array carry same number of cells?
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Walter Roberson
2018-2-2
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!