1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>FLIPLR Reverse the Columns of a Matrix
</TITLE>
</HEAD>
<BODY>
<H2>FLIPLR Reverse the Columns of a Matrix
</H2>
<P>
Section: <A HREF=sec_array.html> Array Generation and Manipulations </A>
<H3>USAGE</H3>
Reverses the columns of a matrix. The syntax for its use is
<PRE>
y = fliplr(x)
</PRE>
<P>
where <code>x</code> is matrix. If <code>x</code> is an N-dimensional array then
the second dimension is reversed.
<H3>Example</H3>
The following example shows <code>fliplr</code> applied to a 2D matrix.
<PRE>
--> x = int32(rand(4)*10)
x =
6 2 7 1
1 10 10 4
7 7 6 3
8 0 8 5
--> fliplr(x)
ans =
1 7 2 6
4 10 10 1
3 6 7 7
5 8 0 8
</PRE>
<P>
For a 3D array, note how the columns in each slice are flipped.
<PRE>
--> x = int32(rand(4,4,3)*10)
x =
(:,:,1) =
2 10 7 5
0 4 5 6
6 2 3 5
2 0 9 6
(:,:,2) =
3 3 8 5
1 7 2 5
4 6 8 4
7 1 6 1
(:,:,3) =
3 3 9 2
5 3 7 6
3 3 3 9
6 4 0 8
--> fliplr(x)
ans =
(:,:,1) =
5 7 10 2
6 5 4 0
5 3 2 6
6 9 0 2
(:,:,2) =
5 8 3 3
5 2 7 1
4 8 6 4
1 6 1 7
(:,:,3) =
2 9 3 3
6 7 3 5
9 3 3 3
8 0 4 6
</PRE>
<P>
</BODY>
</HTML>
|