tags:

views:

53

answers:

1

I have a 3-d matrix with the following dimensions 6-2-10. I want the row dimension to switch places with the heigh dimension, ie 10-2-6. Reshape doesn't achieve this the way I want.

How can this be done? Can I rotate the matrix?

+8  A: 

I think you're looking for permute. For your case it's, permute(A,[3 2 1]);. Here's a description of permute from the documentation:

B = permute(A,order) rearranges the dimensions of A so that they are in the order specified by the vector order. B has the same values of A but the order of the subscripts needed to access any particular element is rearranged as specified by order. All the elements of order must be unique.the elements of order must be unique.

It's similar to transposing a 2D matrix.

Jacob

related questions