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
 5  1  4  4  9  
 2  3  5  2  7  
 7  1  6  7  6  
 0  9  5  5  5  
(:,:,2) = 
 
Columns 1 to 5
 3  1  1  0  9  
 1  5  7  8  2  
 1  3  8  3  3  
 2  9  4  7  4  
(:,:,3) = 
 
Columns 1 to 5
 0  3  4  2  4  
 5  5  7  6  6  
 6  2  6  0  0  
 2  8  3  1  1  
--> flipdim(x,1)
ans = 
  <int32>  - size: [4 5 3]
(:,:,1) = 
 
Columns 1 to 5
 0  9  5  5  5  
 7  1  6  7  6  
 2  3  5  2  7  
 5  1  4  4  9  
(:,:,2) = 
 
Columns 1 to 5
 2  9  4  7  4  
 1  3  8  3  3  
 1  5  7  8  2  
 3  1  1  0  9  
(:,:,3) = 
 
Columns 1 to 5
 2  8  3  1  1  
 6  2  6  0  0  
 5  5  7  6  6  
 0  3  4  2  4  
--> flipdim(x,2)
ans = 
  <int32>  - size: [4 5 3]
(:,:,1) = 
 
Columns 1 to 5
 9  4  4  1  5  
 7  2  5  3  2  
 6  7  6  1  7  
 5  5  5  9  0  
(:,:,2) = 
 
Columns 1 to 5
 9  0  1  1  3  
 2  8  7  5  1  
 3  3  8  3  1  
 4  7  4  9  2  
(:,:,3) = 
 
Columns 1 to 5
 4  2  4  3  0  
 6  6  7  5  5  
 0  0  6  2  6  
 1  1  3  8  2  
--> flipdim(x,3)
ans = 
  <int32>  - size: [4 5 3]
(:,:,1) = 
 
Columns 1 to 5
 0  3  4  2  4  
 5  5  7  6  6  
 6  2  6  0  0  
 2  8  3  1  1  
(:,:,2) = 
 
Columns 1 to 5
 3  1  1  0  9  
 1  5  7  8  2  
 1  3  8  3  3  
 2  9  4  7  4  
(:,:,3) = 
 
Columns 1 to 5
 5  1  4  4  9  
 2  3  5  2  7  
 7  1  6  7  6  
 0  9  5  5  5