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

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