FLIPUD Reverse the Columns of a Matrix

Section: Array Generation and Manipulations

USAGE

Reverses the rows of a matrix. The syntax for its use is
   y = flipud(x)

where x is matrix. If x is an N-dimensional array then the first dimension is reversed.

Example

The following example shows flipud applied to a 2D matrix.
--> x = int32(rand(4)*10)
x = 
  <int32>  - size: [4 4]
 
Columns 1 to 4
 4  8  0  7  
 0  4  4  2  
 1  9  4  8  
 4  7  2  0  
--> flipud(x)
ans = 
  <int32>  - size: [4 4]
 
Columns 1 to 4
 4  7  2  0  
 1  9  4  8  
 0  4  4  2  
 4  8  0  7  

For a 3D array, note how the rows in each slice are flipped.

--> x = int32(rand(4,4,3)*10)
x = 
  <int32>  - size: [4 4 3]
(:,:,1) = 
 
Columns 1 to 4
 0  2  3  1  
 5  5  9  7  
 4  2  3  6  
 2  8  7  2  
(:,:,2) = 
 
Columns 1 to 4
 5  4  0  1  
 5  7  9  2  
 4  3  7  9  
 8  3  3  2  
(:,:,3) = 
 
Columns 1 to 4
 9  4  4  2  
 8  8  7  3  
 4  8  6  2  
 6  7  0  8  
--> flipud(x)
ans = 
  <int32>  - size: [4 4 3]
(:,:,1) = 
 
Columns 1 to 4
 2  8  7  2  
 4  2  3  6  
 5  5  9  7  
 0  2  3  1  
(:,:,2) = 
 
Columns 1 to 4
 8  3  3  2  
 4  3  7  9  
 5  7  9  2  
 5  4  0  1  
(:,:,3) = 
 
Columns 1 to 4
 6  7  0  8  
 4  8  6  2  
 8  8  7  3  
 9  4  4  2