Clear Filters
Clear Filters

How to convert a 4D double matrix into a cell array

16 views (last 30 days)
Hi fellows;
I am having a 4D matrix, X (376 * 30 * 20 *44).
i want to convert the X matrix into the a cell array of (1*44), where every row in the output will be (376 * 30 * 20).
I have tried the following code, but does not work.
Anything will be appreciated .
A= num2cell (X, 376, 30, 20,[]);

Accepted Answer

Stephen23
Stephen23 on 17 Feb 2022
A = rand(376,30,20,44);
C = num2cell(A,1:3);
C = reshape(C,1,[])
C = 1×44 cell array
{376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double} {376×30×20 double}

More Answers (0)

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!