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 is
   y = flipdim(x,n)

where x is matrix, and n is the dimension to reverse.

Example

The following examples show some uses of flipdim on N-dimensional arrays.
--> x = int32(rand(4,5,3)*10)
x = 
  <int32>  - size: [4 5 3]
(:,:,1) = 
 
Columns 1 to 5
 8  0  2  6  6  
 2  0  6  9  5  
 4  5  6  2  9  
 5  3  8  1  6  
(:,:,2) = 
 
Columns 1 to 5
 7  7  4  2  4  
 5  8  5  3  1  
 2  2  7  9  9  
 6  0  7  0  2  
(:,:,3) = 
 
Columns 1 to 5
 3  2  0  7  1  
 4  6  0  6  3  
 5  2  1  7  2  
 6  2  6  7  1  
--> flipdim(x,1)
ans = 
  <int32>  - size: [4 5 3]
(:,:,1) = 
 
Columns 1 to 5
 5  3  8  1  6  
 4  5  6  2  9  
 2  0  6  9  5  
 8  0  2  6  6  
(:,:,2) = 
 
Columns 1 to 5
 6  0  7  0  2  
 2  2  7  9  9  
 5  8  5  3  1  
 7  7  4  2  4  
(:,:,3) = 
 
Columns 1 to 5
 6  2  6  7  1  
 5  2  1  7  2  
 4  6  0  6  3  
 3  2  0  7  1  
--> flipdim(x,2)
ans = 
  <int32>  - size: [4 5 3]
(:,:,1) = 
 
Columns 1 to 5
 6  6  2  0  8  
 5  9  6  0  2  
 9  2  6  5  4  
 6  1  8  3  5  
(:,:,2) = 
 
Columns 1 to 5
 4  2  4  7  7  
 1  3  5  8  5  
 9  9  7  2  2  
 2  0  7  0  6  
(:,:,3) = 
 
Columns 1 to 5
 1  7  0  2  3  
 3  6  0  6  4  
 2  7  1  2  5  
 1  7  6  2  6  
--> flipdim(x,3)
ans = 
  <int32>  - size: [4 5 3]
(:,:,1) = 
 
Columns 1 to 5
 3  2  0  7  1  
 4  6  0  6  3  
 5  2  1  7  2  
 6  2  6  7  1  
(:,:,2) = 
 
Columns 1 to 5
 7  7  4  2  4  
 5  8  5  3  1  
 2  2  7  9  9  
 6  0  7  0  2  
(:,:,3) = 
 
Columns 1 to 5
 8  0  2  6  6  
 2  0  6  9  5  
 4  5  6  2  9  
 5  3  8  1  6