FreeMat
FLIPLR Reverse the Columns of a Matrix

Section: Array Generation and Manipulations

USAGE

Reverses the columns of a matrix. The syntax for its use is

   y = fliplr(x)

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

Example

The following example shows fliplr applied to a 2D matrix.

--> x = int32(rand(4)*10)

x = 
  6  4  7  4 
  8  5  4  1 
  5  8  7  9 
  1 10  9  9 

--> fliplr(x)

ans = 
  4  7  4  6 
  1  4  5  8 
  9  7  8  5 
  9  9 10  1 

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

--> x = int32(rand(4,4,3)*10)

x = 

(:,:,1) = 
  4  8  1  8 
  1  5  5  2 
  2 10  5  8 
  4  8  2  1 

(:,:,2) = 
  0  3  4  1 
  6  6 10  8 
  4  3  3  6 
  2  9  7  3 

(:,:,3) = 
  6  5  1  1 
  6  8 10  3 
  4  3  7  9 
  9  4  4  3 

--> fliplr(x)

ans = 

(:,:,1) = 
  8  1  8  4 
  2  5  5  1 
  8  5 10  2 
  1  2  8  4 

(:,:,2) = 
  1  4  3  0 
  8 10  6  6 
  6  3  3  4 
  3  7  9  2 

(:,:,3) = 
  1  1  5  6 
  3 10  8  6 
  9  7  3  4 
  3  4  4  9