FLIPUD Reverse the Columns of a Matrix
Section: Array Generation and Manipulations
USAGE
Reverses the rows of a matrix. The syntax for its use isy = flipud(x)
where x
is matrix. If x
is an N-dimensional array then
the first dimension is reversed.
Example
The following example showsflipud
applied to a 2D matrix.
--> x = int32(rand(4)*10) x = 0 7 2 6 5 7 10 1 2 6 8 0 1 0 9 8 --> flipud(x) ans = 1 0 9 8 2 6 8 0 5 7 10 1 0 7 2 6
For a 3D array, note how the rows in each slice are flipped.
--> x = int32(rand(4,4,3)*10) x = (:,:,1) = 8 4 6 7 6 0 7 6 8 9 9 0 1 2 10 5 (:,:,2) = 9 6 2 8 3 10 1 7 6 10 9 8 3 2 4 2 (:,:,3) = 3 1 5 0 0 6 5 1 9 4 9 2 6 10 8 10 --> flipud(x) ans = (:,:,1) = 1 2 10 5 8 9 9 0 6 0 7 6 8 4 6 7 (:,:,2) = 3 2 4 2 6 10 9 8 3 10 1 7 9 6 2 8 (:,:,3) = 6 10 8 10 9 4 9 2 0 6 5 1 3 1 5 0