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

7 ビュー (過去 30 日間)
sruthy shankar
sruthy shankar 2018 年 2 月 2 日
回答済み: Walter Roberson 2018 年 2 月 2 日
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?

回答 (1 件)

Walter Roberson
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), :);

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by