Split every matrix in cell and make it into different cell

2 ビュー (過去 30 日間)
KAI-YANG WANG
KAI-YANG WANG 2021 年 9 月 5 日
回答済み: per isakson 2021 年 9 月 5 日
I have a cell which size is 20000x1 and it contains a 32x32x2 matrix in every cell, can i split the cell into two 20000x1 cell and each of them contains the 32x32x1 data?

採用された回答

per isakson
per isakson 2021 年 9 月 5 日
One way
%%
M = ones(32,32,2,3); % Sample data (20000 replaced by 3)
C = mat2cell( M, 32, 32, 2, ones(1,3) );
%%
C = squeeze( C )
C = 3×1 cell array
{32×32×2 double} {32×32×2 double} {32×32×2 double}
%%
[C1,C2] = cellfun( @(m) deal(m(:,:,1),m(:,:,2)), C, 'uni',false )
C1 = 3×1 cell array
{32×32 double} {32×32 double} {32×32 double}
C2 = 3×1 cell array
{32×32 double} {32×32 double} {32×32 double}

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by