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

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

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x
0 ~4 B' Y/ |/ F8 W2 v- Q8 _: ~- \6 k
fliplr
, e# I" L) z/ H: XFlip array left to right+ m+ l& e: `2 d
. r1 a9 T% |9 M4 K- K" _8 @  O
  v- s/ X. p, ?. v( q" [6 E# b' K- B
Syntax, S% o) V6 b& i
7 Y8 `6 K( B0 M( Z7 Z6 V, O
B = fliplr(A)7 M% F. \: _' w- C- |: b4 c5 Z
$ A5 K% @3 m2 u* D4 @( h

8 z$ O+ R- n! `% ]8 RDescription
4 {' m5 \! m; C; s0 V
/ }/ W- n6 }9 l4 q& Z; E% t1 c  l9 f
B = fliplr(A) returns A with its columns flipped in the left-right direction (that is, about a vertical axis).
, G/ T* \( `% p2 p  S. f; g  u& y' b7 i
B = fliplr (a) 返回 A, 其列在左右方向 (即关于垂直轴) 反转。8 k( L& N3 g" V$ m7 M6 @
2 w" x: G9 h& U- ]9 [# O+ C4 p
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 h7 H# \8 T: j
+ S6 B$ E9 T! k, m. [; c( i% z" }0 d
如果 a 是行向量, 则 fliplr (a) 返回与其元素的顺序反转的相同长度的向量。如果 a 是列向量, 则 fliplr (a) 只是返回 a。对于多维数组, fliplr 在由第一个和第二个维度形成的平面上运行。
/ K6 ~9 ~5 J0 C
. L1 U( P8 E: k; P4 K$ e' M% @. U$ x1 a% y/ v7 Z
Flip Row Vector4 e5 H5 }0 b+ ?" Y

- h, u: l0 y. B' h* }Create a row vector.
1 q7 D; p/ R0 B8 _
  Y0 m; Y/ d' p1 j2 XA = 1:10  a3 j& j# X! ~
: T, A9 P3 r6 B( |" x& i3 x9 M/ N) \
A = 1×10" O' M$ h2 f$ [: ]3 ]% J/ x

/ l# l/ h& v+ \4 L- O3 V; j+ p* v5 W     1     2     3     4     5     6     7     8     9    106 q/ Y" `* n5 q( L
7 q1 r( c& y1 T
Use fliplr to flip the elements of A in the horizontal direction." g& ]' J5 G9 K, P9 q' W/ b

; e9 n3 R' S. A, Q6 S" B. [B = fliplr(A)
8 A" U( U1 u" w: G+ g3 J: y
: W2 S% n+ K: j5 o. P( mB = 1×10, G9 r/ C+ w: U' N; q

) U) m! n* p3 b    10     9     8     7     6     5     4     3     2     1% F' r2 R1 M6 C& B

5 H: U' n4 @: h3 f: n% v6 QThe order of the elements in B is reversed compared to A.
7 o% V0 S; b# I2 D! x% F# [8 i3 j1 i2 p4 h& X( P* }

/ j. Q) s0 I6 m, o5 _2 o' ]Flip Cell Array of Characters
9 I. V0 e0 u9 z- X& v6 g& Q* L
) u  a& ]0 e& N$ |/ J2 g; l4 ~0 @  w# c
Create a 3-by-3 cell array of characters.
: L& n% K8 G& n; M% w  _% D
: Q* x3 Z0 Y+ T% ]" RA = {'a' 'b' 'c'; 'd' 'e' 'f'; 'g' 'h' 'i'}
% n/ H6 H2 o3 m* J" n' h# t
. d. l% o$ \6 U  \: H/ FA = 3x3 cell array. Q0 M" z4 ?4 h5 g$ v
    {'a'}    {'b'}    {'c'}' p2 n8 E  K. P* u0 J) ~2 T
    {'d'}    {'e'}    {'f'}/ d! @! P9 k. `
    {'g'}    {'h'}    {'i'}- A; N4 c5 D3 \3 H  u8 @
# w) L+ _% r7 y4 l( ]* T
Change the order of the columns in the horizontal direction by using fliplr.
6 M  f. c, y/ _& h* m5 L& d
( }7 N8 R/ j; {$ _B = fliplr(A)
$ F# h/ ?' K- F9 B- F& E
( `, ?: J* b% P2 ~: k- S; `3 s9 X' g, RB = 3x3 cell array: y7 d3 z% s  O' o
    {'c'}    {'b'}    {'a'}' Z' `' z$ s1 L! \0 ?
    {'f'}    {'e'}    {'d'}  [+ j) @. G  u8 u
    {'i'}    {'h'}    {'g'}
/ e9 L( a! K3 e0 V$ ?% b2 H, c9 \' p. G* L2 F# {/ U
The order of the first and third columns of A is switched in B, while the second column remains unchanged.
7 E1 i% a/ s4 X  @" m
' J1 ]. X& [" v2 ^- {/ m2 j3 \% h+ ^. C. m+ ~& l7 M
Flip Multidimensional Array/ q: ?' |& `& c3 W- `3 M) q( N

- Z+ C, b7 U; H5 MCreate a multidimensional array.
3 u" `8 Z' e$ P9 I8 J1 m$ ~6 \! d; l" W4 m6 m* [
A = cat(3, [1 2; 3 4], [5 6; 7 8])' |' H3 {1 d" o- Z' c, m9 r9 @

+ m; h& Y0 e7 L7 f8 R; a0 JA =
9 M+ ]$ P- }- a) G6 @7 t- o8 WA(:,:,1) =
# O0 E0 o2 B' V; x- b' F
9 K5 c7 F8 K  p9 L     1     27 M6 S3 g4 X' N) i0 \/ I
     3     4/ A8 O: f* Z9 r# i! ^- n0 y% N

; d& N/ f/ f8 K! v8 _2 h; n5 n3 _% [6 O2 Z  C/ k8 j. p, h) V: E
A(:,:,2) =7 f: p* _1 r( g

. ^5 ^! O  ?" g- u     5     6
# F  w9 c; Q, [# a1 S     7     85 H! P3 a) j  o
, a: F/ K% R. Z( g
A is an array of size 2-by-2-by-2.# `2 H  Y. a  }4 z

2 l# r* [; l& _9 L$ aFlip the elements on each page of A in the horizontal direction.
( y$ d/ s1 l: y( w# u4 a$ D# K3 G- r: w! F, w) |: ?" A
B = fliplr(A)0 }- q( k. ]* ?; y) T5 r4 f! D
4 B! J& |3 D# U8 s% {/ d( h
B = , f# H! m# d: E4 }3 V8 I
B(:,:,1) =
8 |3 M0 \* p, q( q
) b$ o3 i* m+ D& F     2     1
9 p" h7 X+ A7 Q* _4 I8 Z     4     3
+ r; ?& `# n" U3 A/ V, T% n# k2 P6 f* [

2 H) `2 B8 ]3 ~) m4 O# |B(:,:,2) =" g2 l5 O. K6 V0 t

2 C) x2 i2 x- O) s. g  Z     6     5* t( w) @& e5 E. I
     8     7& V; y% z# d3 a5 V

0 L. J8 v* N8 `4 [, A6 E1 v3 Q结果 B 与 A 的大小相同, 但元素的水平顺序被翻转。操作会单独翻转每个页面上的元素。
; H- ]$ Z; {" G0 U6 N" E
, ]  w- {+ o8 N/ M* e! S; B
$ i# n6 e# e8 r' i/ X1 ^  f/ w$ L

该用户从未签到

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-23 21:54 , Processed in 0.140625 second(s), 23 queries , Gzip On.

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

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

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