MATLAB: How to convert from cell array to multidimensional array

cell arraysmatrix manipulationmultidimensional array

I have a cell array that is 3×3 with each cell containing a vector of (1×1024). It is essentially the same as a 3×3 matrix with a dimension of 1024. How can I convert from cell array to multidimensional array that has these dimensions of (3,3,1024)? I tried cell2mat, but it simply concatenates them into a 3×3072 matrix.

Best Answer

A -your cell array [3 x 3].
Z = cellfun(@(x)reshape(x,1,1,[]),A,'un',0);
out = cell2mat(Z);