|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
( U) d9 F' Y) f0 W6 c
fliplr4 [2 X/ s8 G5 ?: K' I$ {
Flip array left to right
' S6 e% O3 _1 B/ u }% J* L# g* b' s) Q4 q* r
2 G7 Z8 b8 J- c8 a0 G1 g+ _Syntax6 K; T5 `/ v X# ~
" t( I1 C; W7 w0 EB = fliplr(A)
1 ~- K3 }) v% w: a* k0 j/ [# i' V
# ~: |2 Y; o9 u: E1 A0 \$ CDescription
K1 L5 `8 I9 R9 S9 f" R! l |( o$ w; ^. s
B = fliplr(A) returns A with its columns flipped in the left-right direction (that is, about a vertical axis).
6 o3 Y7 Q1 w' ]+ S/ G/ W/ d
7 O+ K" {; K- W4 z5 jB = fliplr (a) 返回 A, 其列在左右方向 (即关于垂直轴) 反转。* A$ v3 U: ]- j$ b% o
6 N2 i, n; `3 k+ ^3 a
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.
0 l0 q& B2 q8 ^" ?1 y0 N' A
8 J. R# p; i( c* G如果 a 是行向量, 则 fliplr (a) 返回与其元素的顺序反转的相同长度的向量。如果 a 是列向量, 则 fliplr (a) 只是返回 a。对于多维数组, fliplr 在由第一个和第二个维度形成的平面上运行。# D9 c x5 _, w, l: B* I, u
. |- [+ I6 B' @/ z# V* B
. N/ y4 { j O7 [* K+ |Flip Row Vector
9 Y1 C q, W% a% D( k. {/ Y- H5 L4 ?
Create a row vector.
+ V5 ?* g0 C. Y1 V; H( H$ V( v1 s, k1 t+ U, n! p* @$ t
A = 1:107 B9 s" g2 ^4 t5 X) f5 |7 k: E
9 w0 ?3 X; }* m8 O' R, M
A = 1×10
9 A9 h. x/ R! a7 Q- b6 W
6 d3 M2 ~* Z- d6 C# ^5 D. } 1 2 3 4 5 6 7 8 9 10
1 ?5 _$ M7 g1 T! d& L
1 s0 K8 F0 p1 f3 KUse fliplr to flip the elements of A in the horizontal direction.5 w1 g. I8 o R/ @
9 b+ ~4 `2 h0 GB = fliplr(A)# g. V; H4 G9 S5 \$ c6 j( {
; b: ?9 Q+ Q* C% E# y$ Y0 gB = 1×107 L4 U. W9 ~) S. o) |$ R/ \9 U
2 _, ~' e7 d* C/ T$ Q0 j# x" R 10 9 8 7 6 5 4 3 2 16 p' M- {1 J( O" a H) W/ j
; F. C: k# d* u r, v# _/ TThe order of the elements in B is reversed compared to A.
8 ]/ D" U; ^5 Y; C& _* Q2 ?4 h- }. }" \( j+ Q" _1 X7 c
" g6 k8 B* Y1 bFlip Cell Array of Characters
7 P. I4 E: C2 G) n: @
) T2 ^6 P( t5 S1 s
" S q& s" F9 R2 g- B. |0 ^; y! HCreate a 3-by-3 cell array of characters.
' s0 d% |/ G) l4 u$ o" e" ~' c- n9 p
A = {'a' 'b' 'c'; 'd' 'e' 'f'; 'g' 'h' 'i'}$ j1 ~* O, j" i m% Y
3 I1 Y' K' c. C% [! UA = 3x3 cell array6 u& [# ~) d' v( r& J/ m
{'a'} {'b'} {'c'}
; Z' ?. Z( a ?) w3 s0 R0 i {'d'} {'e'} {'f'}+ M- }9 a* }, ?; W
{'g'} {'h'} {'i'}
- Q9 q' q1 @; h$ r' S" _0 e% d8 u) D2 r6 U6 R* ?
Change the order of the columns in the horizontal direction by using fliplr.' V& {; E9 V# W' P
3 l/ R7 j; P8 d6 c2 z
B = fliplr(A)
3 M0 @5 @. d+ l2 `, C% p. x/ w4 v$ q$ A# y
B = 3x3 cell array
. ~$ Z R2 n$ H2 i- w {'c'} {'b'} {'a'}6 O& S' q5 m4 I* V8 ~
{'f'} {'e'} {'d'}
! H7 g) f2 n+ P' x/ W, q {'i'} {'h'} {'g'}8 a7 j5 G* ?2 k/ R
- |9 ]. c9 E: s2 @/ {The order of the first and third columns of A is switched in B, while the second column remains unchanged.% W' |$ m6 ^5 z( F
5 b% z* r+ B# f) i$ C
4 X/ K5 I: c) C/ N9 W
Flip Multidimensional Array7 l) M. R9 l" Q) Q& w
1 U4 Z7 J; B3 F7 D# `2 X! gCreate a multidimensional array.
/ J6 d r: i" R! E! N7 F u: C5 W8 {. g% v( S2 }* A4 ?8 o- K$ u* w( A
A = cat(3, [1 2; 3 4], [5 6; 7 8])
2 [0 E; h3 i; c0 c& Y+ N) ^8 S6 v% J6 Z1 ]9 m. k& R
A = - @, P# O5 o/ Y
A(:,:,1) =
4 L# z; O( @6 W1 g/ \
9 u* U: U( P: a, A3 E) V& Q 1 2& T9 {2 f& [ |# y! |
3 4
2 {: b& v" ^4 X/ H3 B) X1 D v, @( J+ H$ K M" y/ w
, C7 l9 i$ p9 O; P; J! y1 N' f% [# YA(:,:,2) =
8 O) z7 @. G9 r+ T) y2 l$ Y+ J3 O& E' R) |8 y
5 6
, ^3 `2 c, R! n" L. c8 o. J 7 83 y+ u+ w2 v6 t' a
$ B) D2 q8 q1 H2 N/ U/ q6 G/ f
A is an array of size 2-by-2-by-2.
! o6 e( Y$ b0 d, D I; A4 `- w2 Y8 b3 h" z7 ^0 ?' Y8 }
Flip the elements on each page of A in the horizontal direction.
; L/ ~9 F( \: a1 e s* N: Z1 o0 T( M% \& E7 a* X
B = fliplr(A)1 f7 L! U' F5 q' ~4 c
9 l& V( m% }# t: s: y4 |) {" x
B =
/ R$ |7 b( V3 `! nB(:,:,1) =6 ?$ Q' Q/ ^8 f1 N1 u
( l& \1 S3 ~2 k9 J; O: h/ Z) T
2 1
* Q8 ~" N6 p: |8 \+ D 4 3% H3 a/ L! ]( v; V
# w4 m7 k4 ^3 _9 F$ O: E3 H5 C0 T
# H \& a" ?( p0 t& v1 FB(:,:,2) =
. T( j8 ?+ `3 u1 H! @( |" F) e( b# ?& h6 O. F `! d
6 5
5 s$ D) k! Y+ w# z( j# V 8 7
" ]' O# X- {. C9 Y: B Z: e9 \
/ w l* F; W7 T6 N& [结果 B 与 A 的大小相同, 但元素的水平顺序被翻转。操作会单独翻转每个页面上的元素。! ^/ [& Y1 ?( x, Y3 ]* Q4 R* O
4 Y L* J1 S7 P, F' [8 E0 o
( ~6 ?. t* ?+ c9 X& @4 z
|
|