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