How to convert 32x32x2x20000 into 20000x1 cell array?

1 view (last 30 days)
KAI-YANG WANG on 3 Sep 2021
Answered: Matt J on 5 Sep 2021
How to convert 32x32x2x20000 into 20000x1 cell array, I got a data from the output of a cnn network and i would llike to convert the 32x32x2x20000 into 20000x1 cell array and in each cell has the 32x32x2 data. Deos anyone can help, Thank you !
0 CommentsShowHide -1 older comments

Sign in to comment.

Accepted Answer

per isakson on 5 Sep 2021
Edited: per isakson on 5 Sep 2021
A mat2cell example
%%
M = ones(32,32,2,6); % Sample data (20000 replaced by 6)
C = mat2cell( M, 32, 32, 2, ones(1,6) );
%%
C = squeeze( C );
C
C = 6×1 cell array
{32×32×2 double} {32×32×2 double} {32×32×2 double} {32×32×2 double} {32×32×2 double} {32×32×2 double}
0 CommentsShowHide -1 older comments

Sign in to comment.

More Answers (2)

Fangjun Jiang on 3 Sep 2021
mat2cell() ?
0 CommentsShowHide -1 older comments

Sign in to comment.

Matt J on 5 Sep 2021
A = rand(32,32,2,20);
C=num2cell(A,[1,2,3]);
C=C(:)
C = 20×1 cell array
{32×32×2 double} {32×32×2 double} {32×32×2 double} {32×32×2 double} {32×32×2 double} {32×32×2 double} {32×32×2 double} {32×32×2 double} {32×32×2 double} {32×32×2 double} {32×32×2 double} {32×32×2 double} {32×32×2 double} {32×32×2 double} {32×32×2 double} {32×32×2 double}
0 CommentsShowHide -1 older comments

Sign in to comment.

R2019a

Community Treasure Hunt

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

Start Hunting!