0
votes

I looked through past answers but I could find one that gave me a definitive answer for my case (weird as it seems simple).

I have a mxn cell array with each having a tx1 matrix and I would like to reshape this to a mxnxt 3D matrix. I saw a few example with permute and remat but did not get my answer there.

Thanks!

1
As a matter of semantics, there is no such thing as a "3D matrix." Technically, it would be a "rank 3 array," or a "3D array." Matrices are inherently 2D.Jeff Irwin

1 Answers

1
votes

You just need cell2mat with a little of permute:

c = repmat({(1:4).'},2,3); %'// example cell array
result = permute(cell2mat(permute(c,[3 1 2])), [2 3 1])