找回密码
 注册
关于网站域名变更的通知
查看: 772|回复: 2
打印 上一主题 下一主题

MATLAB的fliplr 函数介绍,这个函数可以实现从左到右翻转阵列

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2020-1-8 10:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x
4 g1 T& J; ]0 r/ e/ n1 G- L
fliplr+ _0 _: K6 ^' ?
Flip array left to right2 r0 f' X7 V( m6 F% ]% a

4 P) G; X  P! x! a6 K3 f+ F+ g1 `) Z! n( L# F
Syntax
* g. m- L9 E$ o' h1 q. U7 s: n9 N: h: ?. [& r
B = fliplr(A)
) s8 r/ X. O  l( ?* o
8 P3 c: |8 M7 Y3 I8 V
8 M4 i: ^  T: v- j" o* lDescription

/ |  ^1 }/ v& i/ i0 i$ E# M' P# O( U$ t# I  d
B = fliplr(A) returns A with its columns flipped in the left-right direction (that is, about a vertical axis).$ g" g" z/ X; H# ^2 U" k

; b, V' b6 ]( n5 E' bB = fliplr (a) 返回 A, 其列在左右方向 (即关于垂直轴) 反转。8 G! z' K, T( l9 `5 U
% l' q/ b! s% `1 y5 C$ O
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.( m8 p7 d2 z, {  b& j4 m
! @( I0 j6 O# A' @: z' n
如果 a 是行向量, 则 fliplr (a) 返回与其元素的顺序反转的相同长度的向量。如果 a 是列向量, 则 fliplr (a) 只是返回 a。对于多维数组, fliplr 在由第一个和第二个维度形成的平面上运行。6 e2 b  X! [6 c( F

, P( w1 X; i& Z9 \$ z; ^* D
! Z7 i* Z( v2 x5 v9 iFlip Row Vector% P( @  T0 D6 o( F/ S4 R
7 W: \/ ^1 c+ N4 e4 |
Create a row vector.2 z% \0 S6 P1 d. a
& i# \) Q& h1 J5 K9 @- S6 ~
A = 1:103 |' m: s5 P7 j) j" N8 J  T

! ?) W5 O; M# n6 v7 a/ IA = 1×10
) b) x( Y% T. p' L& ~+ a+ R; I& G% L6 j+ J( C! l
     1     2     3     4     5     6     7     8     9    101 q# n1 Q' a! }

+ k( L& u  W: X; lUse fliplr to flip the elements of A in the horizontal direction.
& g! i+ `: C" i  b) U7 ]0 H9 q  g% N' H  T+ H* b. ^! s; S
B = fliplr(A); l  `5 `. V& L, M
/ k) H* q) k! E6 R; W  m& z& l
B = 1×102 ]- ]/ q* |6 @8 D
  a7 L/ r# n. y$ G% F" I/ B
    10     9     8     7     6     5     4     3     2     18 M* p* k7 K: \% n5 g

& i# L  W5 z0 y& fThe order of the elements in B is reversed compared to A.$ P1 |6 {! E. q

, U4 T1 |. i: i: [: Z* T" b$ M2 D8 t8 `# O! p
Flip Cell Array of Characters, O$ c! P' R8 k" Q$ T" ~9 \3 X
, X* j% r2 Z5 P3 v* Y
+ P/ t/ _: d& w% O
Create a 3-by-3 cell array of characters.
; q, Q* a% J% w
+ m* j4 B& Q$ L9 \A = {'a' 'b' 'c'; 'd' 'e' 'f'; 'g' 'h' 'i'}
# T8 _) u; k: s- i. \5 G7 z9 g! a
: c- u& E( Q  F, b2 U) Q8 ~A = 3x3 cell array0 o, L5 x6 b' K5 a" O
    {'a'}    {'b'}    {'c'}+ M1 v, Y+ G* [* {3 f; s3 ?
    {'d'}    {'e'}    {'f'}
  H% U- k& s9 P  F; U    {'g'}    {'h'}    {'i'}
& n& g8 Q0 t+ o5 e. C7 i- ]$ A9 T$ E3 _3 n4 v
Change the order of the columns in the horizontal direction by using fliplr.
2 `2 x6 g/ |: `/ @% m- w
: q* R; \& r0 _6 t. p' ?, p) k) {B = fliplr(A)6 V# L2 g. y& Y- p1 m0 ^; @: j

9 E( a7 r& l! N9 R; S6 g: J7 DB = 3x3 cell array
9 Q- w; T7 B2 j. F: A    {'c'}    {'b'}    {'a'}
; k- \/ {" X) @7 w4 o    {'f'}    {'e'}    {'d'}
& R  k3 U( i6 S) o$ j& f    {'i'}    {'h'}    {'g'}
. [- U; y+ }' K- L
" t6 l+ `, q* S. `8 Z# }) c: }, pThe order of the first and third columns of A is switched in B, while the second column remains unchanged.
+ f% E3 q* R. Y0 ^4 Z  O" n4 l/ w# M! n% h

0 Y: t/ {2 P1 C8 S* GFlip Multidimensional Array
& v& x3 Y9 I' F+ ], g
; Q, p5 O% ]/ b. W2 ?/ ~Create a multidimensional array.
2 t% T+ w& f9 r2 ^- e. [! G! ~$ ?0 X1 c8 x$ l/ F( r
A = cat(3, [1 2; 3 4], [5 6; 7 8])8 q# E8 C4 p- g8 W1 Q- G
! ?2 x  |- f1 _: o7 q+ a0 D( M3 K
A = 7 W/ W3 N$ L0 b+ p4 y* l
A(:,:,1) =
+ Z" u9 E6 [% s: V4 F
+ C% T- ]9 |3 V; u) {6 r7 m) `& G     1     29 z+ f. [. E! {& d4 s% N
     3     4
3 p7 a- T* O2 a; V$ X( R. L
9 N% S7 m: I' s4 ~. z5 L5 S5 u4 R9 c8 e1 Z* |* f
A(:,:,2) =
6 c, G5 v- q$ r' H  n
+ E- J5 H& B/ h( t1 g     5     64 k+ {" ]; l+ \+ e6 P2 v, S
     7     8
7 j2 z1 n: r6 u2 f# N0 D: b2 ~9 g/ R; k" P# U# A  v9 V
A is an array of size 2-by-2-by-2.
- t5 u0 ^( c" J' \3 _$ t) U) ^# g3 ^( b  z
Flip the elements on each page of A in the horizontal direction.
. C( Y# ]; h* W, R6 z9 ]- |: r
- X8 i: V, i9 P7 cB = fliplr(A): J/ d3 g8 Z3 e; [" O& O" z3 L

0 n8 u) |2 ^: e% |9 t$ WB = 3 W6 b# l6 Z' ^8 b* ]- v
B(:,:,1) =
% z( P: m3 K$ a- k: m% e0 C
* n. @# s% P! D0 q5 i1 p4 C1 N. Z( k     2     1  K, ^; \/ @+ z3 ]2 S
     4     3; b  R2 }0 \4 E" j% y" s- Z( n9 }

" B! r1 Y& W5 x4 p3 C
2 I$ j) }3 ]! C2 k" |5 f# sB(:,:,2) =3 q( ?6 I( P& r

4 w/ q; {0 H  q$ ]0 _3 ?     6     58 v  m: z* F7 K2 ]9 P
     8     7# r  H: p: n, j& @7 O0 j
/ ~- L  U; {, o, f
结果 B 与 A 的大小相同, 但元素的水平顺序被翻转。操作会单独翻转每个页面上的元素。' e. t5 x* z8 |4 `5 h) E
  P7 E$ r  M6 q; Z+ j

  ^# O; Y% ~# ?. S7 R

该用户从未签到

2#
发表于 2020-1-8 19:15 | 只看该作者
MATLAB的fliplr 函数学习

该用户从未签到

3#
发表于 2020-1-9 19:01 | 只看该作者
MATLAB的fliplr 函数学习
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

推荐内容上一条 /1 下一条

EDA365公众号

关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

GMT+8, 2025-11-1 20:25 , Processed in 0.125000 second(s), 23 queries , Gzip On.

深圳市墨知创新科技有限公司

地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

快速回复 返回顶部 返回列表