FLIPDIM Reverse a Matrix Along a Given Dimension
Section: Array Generation and Manipulations
USAGE
Reverses an array along the given dimension. The syntax for its use isy = flipdim(x,n)
where x
is matrix, and n
is the dimension to reverse.
Example
The following examples show some uses offlipdim
on N-dimensional
arrays.
--> x = int32(rand(4,5,3)*10) x = (:,:,1) = 5 4 5 3 9 7 7 5 6 7 1 6 8 4 1 5 7 1 8 8 (:,:,2) = 4 1 2 2 2 5 2 3 5 4 0 3 6 8 7 9 2 3 10 8 (:,:,3) = 6 8 9 5 5 5 4 4 2 9 8 0 3 0 10 0 2 6 9 0 --> flipdim(x,1) ans = (:,:,1) = 5 7 1 8 8 1 6 8 4 1 7 7 5 6 7 5 4 5 3 9 (:,:,2) = 9 2 3 10 8 0 3 6 8 7 5 2 3 5 4 4 1 2 2 2 (:,:,3) = 0 2 6 9 0 8 0 3 0 10 5 4 4 2 9 6 8 9 5 5 --> flipdim(x,2) ans = (:,:,1) = 9 3 5 4 5 7 6 5 7 7 1 4 8 6 1 8 8 1 7 5 (:,:,2) = 2 2 2 1 4 4 5 3 2 5 7 8 6 3 0 8 10 3 2 9 (:,:,3) = 5 5 9 8 6 9 2 4 4 5 10 0 3 0 8 0 9 6 2 0 --> flipdim(x,3) ans = (:,:,1) = 6 8 9 5 5 5 4 4 2 9 8 0 3 0 10 0 2 6 9 0 (:,:,2) = 4 1 2 2 2 5 2 3 5 4 0 3 6 8 7 9 2 3 10 8 (:,:,3) = 5 4 5 3 9 7 7 5 6 7 1 6 8 4 1 5 7 1 8 8