How to convert matlab vector to 3D matrix

matlab, matlab-figure

Solution

Use reshape to do it easily:

new_matrix = reshape(s, 64, 40, 60);

Problem

I have a vector `s`, which is of size `1*163840` which comes from `sizeX * sizeY * sizeZ = 64 * 40 * 60`. I want to convert the 1*163840 vector to a 3-dimensional matrix, which has 64 in x-axis, 40 in y-axis, and 64 in z-axis. What is the easiest way to convert it?

Original source