Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert matlab vector to 3D matrix

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?

like image 632
user3761566 Avatar asked Jul 07 '14 01:07

user3761566


1 Answers

Use reshape to do it easily:

new_matrix = reshape(s, 64, 40, 60);
like image 187
Fantastic Mr Fox Avatar answered Sep 28 '22 11:09

Fantastic Mr Fox