Re: Multidimensional array to a matrix.



"Ofer moshe" <mosheo@xxxxxxxxx> writes:

Hello
I have a mutlidimenstional array (i,j,k) i would like to change this
array to a matrix whose number of rows is the number of pages and the
number of columns is the number of elements in each page (rows time
columns in a single page).
In other words for each element (i,j) i need the the values for each
page as a row vector.
Is it possilbe to do this without for loops?

Internally, matrices are stored column-major (in order of the
indices). Reshape does not reorder any elements. Say A has size
m,n,p. Then

reshape(A, [m*n p]) is what you want. For other combinations, permute
would be necessary.


--
Peter Boettcher <boettcher@xxxxxxxxxx>
MIT Lincoln Laboratory
MATLAB FAQ: http://www.mit.edu/~pwb/cssm/
.