next up previous contents
Next: LENGTH Length of and Up: Array Generation and Manipulations Previous: FLIPLR Reverse the Columns   Contents

Subsections

FLIPUD Reverse the Columns of a Matrix

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

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


Samit K. Basu 2005-03-16