MATLAB: Convert a 3D array to a 2D cell array

2d3d3d arrayscell arraysconversion

I'm sure there's a basic way to do this that I haven't found.
I have a 3D array, but I want to convert it into a 2D cell array where each cell contains the data currently contained in the 3rd dimension, so:
if given some 3D array A = rand(10,10,4);
make a 2D cell array B that is 10×10 cells, but each cell contains 1×4.
Thanks so much.

Best Answer

B=num2cell(A,3)