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

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