|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
: Q0 K' {4 e1 |
fliplr
4 b2 h4 n# A# AFlip array left to right
4 U6 K0 C @+ q3 }2 f& ]2 f# j, E( D4 \% h& ?
9 d1 w# w4 ?8 ?
Syntax
* _: X" M0 V- G
& U. n8 }- P/ R3 O, D1 S6 [) _4 DB = fliplr(A)2 ^; P! w0 U& s( p; O9 W8 a/ w
* e" o3 x8 m) P' N" A
8 H$ L1 r1 Z- v% ~4 C- T, ?Description
' O, k3 E0 t# L) s# n4 ]3 g# O! z; K2 j( z h9 O9 D3 Q
B = fliplr(A) returns A with its columns flipped in the left-right direction (that is, about a vertical axis).
0 z/ v! p- q6 m
( M+ G( y2 |# b2 t5 a: pB = fliplr (a) 返回 A, 其列在左右方向 (即关于垂直轴) 反转。 s" Z% E+ w1 ?9 m
4 O* i% @1 Q$ D( ]If A is a row vector, then fliplr(A) returns a vector of the same length with the order of its elements reversed. If A is a column vector, then fliplr(A)simply returns A. For multidimensional arrays, fliplr operates on the planes formed by the first and second dimensions.7 j1 u. r! ~% x8 l' a0 i
6 F! t/ q# l+ x/ C+ \' R- U
如果 a 是行向量, 则 fliplr (a) 返回与其元素的顺序反转的相同长度的向量。如果 a 是列向量, 则 fliplr (a) 只是返回 a。对于多维数组, fliplr 在由第一个和第二个维度形成的平面上运行。) A" o& `$ d2 G' g8 ^% s, S
6 [. F! @; r* N: P, M( o2 ^/ P+ g% h+ q/ i/ H9 z
Flip Row Vector5 w3 {7 F1 l9 z# X$ U8 K3 q: V
8 G0 f% Z' G3 j7 S4 pCreate a row vector.
$ K: P. Z$ T. G6 U) j) V* M
# }( n; e2 n* g3 T6 I8 c( XA = 1:10
8 R: L2 O: Y8 C7 t0 W" [. e1 M- [& i n& [3 V
A = 1×105 i5 \ x9 d3 Q
" L6 ^. z( n+ \7 g, J
1 2 3 4 5 6 7 8 9 10& i( V8 W9 o1 `
7 |7 r5 X& D" k8 QUse fliplr to flip the elements of A in the horizontal direction.4 y, R$ N* f7 j
# J2 J' [+ Q- V! W/ q I) R
B = fliplr(A)0 |( ]5 V* F' i( w
2 ^$ Z v; |* l% P2 j# WB = 1×10 S6 L, i0 K& z+ L5 l& F" k8 y2 U
. n6 H# q3 A, q
10 9 8 7 6 5 4 3 2 1
. w! B0 \$ ]9 G0 S3 O8 C6 d$ {8 l0 \. E% X
The order of the elements in B is reversed compared to A.2 {% R _; @, E1 r3 a z
$ v) C+ h1 f# B( j7 O( P
" w: m8 g! z$ ~5 W% p+ t
Flip Cell Array of Characters# ]: f- n- R% ?8 X% v+ r9 q
) o( g: ^6 B7 i* l; [
9 m4 Z) a9 r9 {2 x! v. SCreate a 3-by-3 cell array of characters.
' E( V7 _3 K6 m4 W' ^5 m( p' F2 W6 a% _( J
A = {'a' 'b' 'c'; 'd' 'e' 'f'; 'g' 'h' 'i'}" J! ?9 B$ J( Z* q1 v( h J- s1 E: @. P
4 y* F" q4 S5 {+ o; q' e6 xA = 3x3 cell array2 ^3 H4 l: ]' A# ?1 S2 M
{'a'} {'b'} {'c'}
+ i/ k) |. Y% B: G2 s {'d'} {'e'} {'f'}
4 {; R" o- z2 V, i/ e3 c {'g'} {'h'} {'i'}, ^, p: ]! y6 A7 q I
( R. T" f0 f$ D0 `; _7 V L& t
Change the order of the columns in the horizontal direction by using fliplr.
1 F5 K8 J7 e/ ]. ?3 J* h% H* Z% W, y, ^$ L8 C
B = fliplr(A)( s( K4 m- N0 k$ @8 a y
: z% E: I& s3 `7 ^# W% H* XB = 3x3 cell array4 e' i2 p% y4 A. x: ^6 |& G
{'c'} {'b'} {'a'}
9 F- j6 b7 K- u& T6 P) Y {'f'} {'e'} {'d'}9 U$ h( \# P4 Q; R5 v; |2 T7 z
{'i'} {'h'} {'g'}
/ V- Z$ x" ?% h% v4 f3 J+ B) B( {
0 n( |- G1 F7 ZThe order of the first and third columns of A is switched in B, while the second column remains unchanged.
) o; Y4 U+ j: o9 F& t9 o
0 j' P4 p( r- ?. P$ A8 E; s( Y2 `( G2 u7 [6 h' q- h% f
Flip Multidimensional Array
# r$ I3 }! y5 [2 Z" i4 U; [- r/ q$ {) I3 a9 O
Create a multidimensional array.8 h; {6 \0 l8 a3 U# y, _0 i$ K% p
/ O8 [( {& `- ]. B: qA = cat(3, [1 2; 3 4], [5 6; 7 8]) @, v0 R0 h+ O" S- l, w
+ Q8 q: P. H# U# H6 B" H6 uA = & h- ~3 h" I9 r3 M1 q) G8 |5 d! @
A(:,:,1) =" u$ D( B) w* h. B! ~3 ?; ?! f
# {* O- | A. j
1 2
. t. I$ D' ^# |8 y0 c$ U1 ^ 3 4! I# E, z0 V, ]
8 N9 |' G; y$ F2 @+ K% E
6 W* `, w: E: n" J! r# J
A(:,:,2) =
; f9 j, p; o* v
& j% b. @+ L: w5 t 5 6
- W+ s$ \7 k8 X7 K$ C$ Z/ f# r 7 8
% I8 d7 l3 p G/ `. h0 \: q! f) o/ q9 B9 f2 @7 {: U* i
A is an array of size 2-by-2-by-2. R( N' w# g" v0 @( Y
: }0 Y7 B2 s$ d# _0 u% Z7 ^) m
Flip the elements on each page of A in the horizontal direction.
9 W8 k) `& x, H/ ~& q/ w+ x# B3 q& ~% `& O& v
B = fliplr(A)1 f6 {- f* X. r/ V( m) H
: ~& O, H* G8 A" U% C4 z' j) b
B =
- K4 @+ k5 U) BB(:,:,1) =( ^9 V# ?0 P) V& N4 r/ Y% M
6 x7 O' K2 D$ V `' j3 x l0 l
2 1( {5 n: J! T, {, {5 Y
4 3
( X! A4 s) ?) u# c0 |- M
% Y u; P! e9 c5 y& o/ W1 b M% l' B/ O0 @0 \( I! C
B(:,:,2) =
+ N- h( H! d& J3 C9 L
! T4 I( v* o8 V; H7 p1 a 6 51 k( O. M0 I; u) S
8 7) K9 i6 p) w) d" Q, y2 A* A
P, v; N% e4 F2 G8 K' }结果 B 与 A 的大小相同, 但元素的水平顺序被翻转。操作会单独翻转每个页面上的元素。
6 j0 F" E! p- ?! h
: X% l. S1 ? y5 O, s9 |: t
& b$ P# T3 e) J8 h |
|