标题: MATLAB的fliplr 函数介绍,这个函数可以实现从左到右翻转阵列 [打印本页] 作者: mytomorrow 时间: 2020-1-8 10:10 标题: MATLAB的fliplr 函数介绍,这个函数可以实现从左到右翻转阵列 # v8 ^. P3 B( ~/ \1 ]( B fliplr + Q! `7 y" x1 s `Flip array left to right " g4 d8 h! L" M) X2 o k# V4 n9 k) c/ c% N" A. h9 D
9 m9 ^' R6 E' R- c7 B( } Syntax . Z2 l) O$ O* U3 u& ]; `6 |. _! B* o3 H2 ]/ A2 H0 P4 a
B = fliplr(A) , z) f: Z% c* Y, X2 Z" `) c8 b" p; M0 Z1 V8 ~ { m/ b, M 4 g- V- ?+ u9 g+ c. j* P
Description4 }( g E3 q4 N! @2 V) b
4 {; l3 p$ N3 J3 ~, G
B = fliplr(A) returns A with its columns flipped in the left-right direction (that is, about a vertical axis). 7 X$ W+ Q8 a* ~2 h& d3 t" T$ A7 d% s9 A3 ^4 x5 \6 `, X
B = fliplr (a) 返回 A, 其列在左右方向 (即关于垂直轴) 反转。 - H. R" i' G' o5 j) Y! L2 h1 p; E 9 w# h; l0 v$ @& D: e+ p! z$ Z) OIf 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.% ~( y# {3 S% }3 G
3 B! ^$ F6 b3 p( F
如果 a 是行向量, 则 fliplr (a) 返回与其元素的顺序反转的相同长度的向量。如果 a 是列向量, 则 fliplr (a) 只是返回 a。对于多维数组, fliplr 在由第一个和第二个维度形成的平面上运行。$ \ k" F1 I+ U5 R3 D* Y0 `
9 S | P) Y9 T/ S
2 x" G) ~$ l& `- J Flip Row Vector r4 F- v9 q- P8 S+ G8 Z; p: R( ]
4 _7 n# F$ }/ J5 b7 p, ECreate a row vector. . F2 \. e, \1 m9 B2 k% Y. U) `! u3 ^& I# J o
A = 1:10 * B4 l$ V: p9 F) l! @" ]& ~8 W 1 n0 f3 |. N+ U; ] W# P$ NA = 1×102 ?3 }2 ~# R/ I+ ]# D# E$ K; l
: H7 G1 C/ e: \ U* `. p" x
1 2 3 4 5 6 7 8 9 10 ' ]( t6 J2 A% g: D& Z( C. Q& |- N 3 a) u- [- b- E' `Use fliplr to flip the elements of A in the horizontal direction.5 X0 g5 I! p j8 d4 j* g
/ ]0 A5 Z- N5 `$ x4 ^, wB = 1×10 3 h8 c; l; _9 h8 c7 ]: u5 s: f / g/ r; d6 P) f7 |) V" ~ 10 9 8 7 6 5 4 3 2 1 9 w' d" ]1 v, M4 @ % r% r# H- r3 HThe order of the elements in B is reversed compared to A. * t+ A; S$ L) k2 P6 j v 8 @' @4 J# j9 X' ?0 ?7 o ( a( c4 s( s# m7 N5 oFlip Cell Array of Characters $ `- |% O5 h* K& L - ], x* c! {% a* O' _9 n1 D. ]1 h) [7 y
Create a 3-by-3 cell array of characters. : {% ]7 A' g' t' \$ Y( U( {3 W4 d5 g! K6 `" D7 j! }; A- G
A = {'a' 'b' 'c'; 'd' 'e' 'f'; 'g' 'h' 'i'} ) W; |0 A; h) E2 N6 ^$ N1 R: o- H# ~' o) x" f+ ~, L
A = 3x3 cell array8 Y6 U$ k6 m- {2 X
{'a'} {'b'} {'c'} 4 Z4 O" _& |8 R5 r7 ]9 _/ p {'d'} {'e'} {'f'}- J( F5 ^2 j$ Y1 u+ l
{'g'} {'h'} {'i'}8 h9 C7 O; b1 w
/ F' l# H9 s& ]2 N' SChange the order of the columns in the horizontal direction by using fliplr.3 U, ^1 K9 g7 F8 n
2 U. ?% U# t6 N5 R
B = fliplr(A)3 M* B% X# [; n- }: L
) l( i( Z( s; X# n( `5 g7 q2 @B = 3x3 cell array7 P0 M& N C/ y( A, w d& f" [
{'c'} {'b'} {'a'}) R7 O1 O1 u8 J. N% U
{'f'} {'e'} {'d'} 8 ~4 \9 T; V0 E' ?) z; f% ?4 G! a {'i'} {'h'} {'g'} ! E+ k% n: Y9 M3 H$ t: h( l) q3 ]- ~5 C& s( V9 u0 m
The order of the first and third columns of A is switched in B, while the second column remains unchanged. G5 U' r$ q! d5 F; o7 k3 q; v/ a/ P2 V5 |% [# J. m, G0 T
4 c! h6 f9 R7 j3 L! v . k7 x5 S' t! X% z1 A3 @" EA(:,:,2) =9 ?+ `# P# ~" [9 x$ j2 n9 {/ D
! R1 t; E$ ^5 K- H2 C; ^6 T
5 6 O9 b. k p6 k1 `& @
7 8 9 T$ K# K; }3 Y0 l w/ _4 c5 P- _) W3 f7 Q/ O, k& A$ Y9 X
A is an array of size 2-by-2-by-2.& }7 n( v c# h$ b# _2 s2 l1 P
5 T, G" a2 P# p3 `
Flip the elements on each page of A in the horizontal direction. " O9 w& R4 }+ S! H; @9 Y v1 v4 U+ ^8 |, S
B = fliplr(A)/ J( J$ D% a) w! F
1 I m1 p- S" v9 j8 T& T( |B = : a8 P* P. z! n# C' e0 V7 J" xB(:,:,1) = - f0 H1 _5 b& C3 m; i, ] 7 @0 h2 Q( s9 ]: ^9 Q, D2 Y 2 1 ! R6 {& i: U& Z 4 3 8 n! Z+ J! w9 r$ V( {9 r8 z2 Q2 w6 H* J1 B5 s
' ]4 _8 h% ~! O7 h* d( x
B(:,:,2) =0 |& m- s5 b1 S: k. a& c8 q
% e- F0 L5 x6 g* N `1 Q4 ~: L
6 5 1 G/ |6 p; F" Q9 D: e6 s1 ~ 8 7 ( Y# n9 ~) O3 S! V 3 u8 w+ O0 D7 O& \7 h结果 B 与 A 的大小相同, 但元素的水平顺序被翻转。操作会单独翻转每个页面上的元素。 1 P- `3 m% J* [7 Z$ C9 v 9 L B# _5 S5 @+ i) {+ y4 a/ z; }7 f9 ^# o$ ]2 h7 _ 作者: CCxiaom 时间: 2020-1-8 19:15
MATLAB的fliplr 函数学习作者: CCxiaom 时间: 2020-1-9 19:01
MATLAB的fliplr 函数学习