Create 3d matrix from existing 2d matrix in Matlab

I have a 2D matrix of dimensions 64 x 727. What I would like to do is separate each of the columns, creating a 3D matrix of dimensions 64 x 1 x 727.

I have looked through several similar questions on here, but my limited matlab ability is preventing me from applying previous answers to my own issue.

Many thanks,





if that doesn't produce what you want explain further.

Try this:

x2d = rand(64, 727);
x3d = reshape(x2d, 64, 1, 727);


permute(matrix,[1 3 2])

switches 2nd and 3rd dimensions

Need Your Help

Associations: Prevent Save if the Collection as a Whole is Invalid

ruby-on-rails activerecord ruby-on-rails-4 associations

I need to validate a model containing an associated collection which requires