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

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

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x
, D  ]/ ?- g) @) d  q3 m, Y
fliplr8 N' `) e; ?9 ^6 j
Flip array left to right: M. y* q- }2 _% ~! ~; H

6 R4 ?* ?' g5 p9 R4 M5 ?
# T( a$ E$ _9 |$ j# oSyntax
6 W- I: M, u: O$ r  N1 C% ~" X: k5 L' G) s8 R- a! L
B = fliplr(A)
. M: ~7 O" L" O2 ~5 v7 i, G- N; X4 n8 s4 r
4 Q# T. a) h- W8 P  }7 W5 _8 q
Description
) i0 I* N, q5 ^& D% Z4 X7 I% k2 Z' K

$ W$ b: E3 ~8 j/ Y1 C2 c& L8 IB = fliplr(A) returns A with its columns flipped in the left-right direction (that is, about a vertical axis).4 U7 U7 ?/ a+ F1 V7 M" u- m4 l
) T& j: B' b3 _5 f6 y
B = fliplr (a) 返回 A, 其列在左右方向 (即关于垂直轴) 反转。
% I" _2 r1 U  y4 Y1 c; }4 i  K1 }1 |8 h( \, s
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 g7 T6 U+ D8 V( \# _
8 T, F' D8 f/ M+ f如果 a 是行向量, 则 fliplr (a) 返回与其元素的顺序反转的相同长度的向量。如果 a 是列向量, 则 fliplr (a) 只是返回 a。对于多维数组, fliplr 在由第一个和第二个维度形成的平面上运行。
/ z- z* ?2 s" j" |4 C; W: Y3 C8 j" ~9 x9 P) x& x( X) z7 ^

7 e/ Y/ f2 ~/ b  L& z- xFlip Row Vector: B+ ^+ V8 s0 H* u& C( I" F

! X2 J1 o$ p" y8 ^1 X/ oCreate a row vector.$ \8 u  h% ^! o9 x! l

" c, `. \* }0 Y- v( O, v. JA = 1:105 q- ?* t" `. E% l& A2 f& R! e

+ d% ~. m, Y8 k( tA = 1×10! p3 l) y# J2 u

6 h9 `" O: M1 \9 y     1     2     3     4     5     6     7     8     9    10
7 W& M0 E9 e. ]# t" l6 `3 B0 n# [5 d% n2 F
Use fliplr to flip the elements of A in the horizontal direction.
* U6 c' k3 q( [8 q9 E: Y: t" D
5 n0 k- @) p( L/ J  QB = fliplr(A)
( g9 h+ y/ e. f9 G& z& p) P# ?8 _5 C: z  `" [7 X3 e) M3 E0 i9 x
B = 1×10
( J5 i" b& K- A' N
6 K+ r& F. `. s) m    10     9     8     7     6     5     4     3     2     1
9 A' V- _% z4 `; L3 p1 d
6 c1 _" L( M. E5 sThe order of the elements in B is reversed compared to A.
/ ^& q9 }7 Z$ g" E' @  ^# [* T
9 s- t* @& i3 D% W5 k% n7 L8 ~
$ z3 F# `0 P4 w; TFlip Cell Array of Characters  q8 K1 U8 c3 `" Y$ K: V
' Q6 F8 R" L1 B) m9 Y1 ?$ e

! |* x$ k9 f1 [; I, ACreate a 3-by-3 cell array of characters.
6 i( Y$ O) [) g. [/ O. v9 Z, Y- x
( u3 f( G5 L& r0 V: QA = {'a' 'b' 'c'; 'd' 'e' 'f'; 'g' 'h' 'i'}
7 g( z' ]$ m  K, s! ^  C9 Z8 i" v2 v& h6 o2 ^
A = 3x3 cell array4 g' Q4 G# I: C0 f
    {'a'}    {'b'}    {'c'}
, K2 L- A" Z5 _$ N) u: b  [    {'d'}    {'e'}    {'f'}: l- t( ~; f7 y$ y. a
    {'g'}    {'h'}    {'i'}1 k3 f. R$ Z% S# x2 L% S/ Y

+ ~1 x4 L; ?) Z* b6 ^0 ~2 b. [# ~$ p) dChange the order of the columns in the horizontal direction by using fliplr.
3 G; l  ]4 S9 H2 J/ i( z( i' x" I, m* e- m& N1 v
B = fliplr(A)
  T$ g+ e. w. z" q& Y  d
" [! X7 z( K8 j( W3 F  c( SB = 3x3 cell array) C8 x; Q9 y9 v( x  w4 Y6 Z4 t
    {'c'}    {'b'}    {'a'}8 ^9 R( `( c% j  J: g9 O( `
    {'f'}    {'e'}    {'d'}
" J  Z$ P" [) n( ^) I    {'i'}    {'h'}    {'g'}0 @" g! R, n! r* v& ^
6 U$ e. W7 d# q( r5 v  J# ?0 E% @
The order of the first and third columns of A is switched in B, while the second column remains unchanged.8 @9 `. P" O' X8 y
0 O+ F1 D( m7 H( s  A- I# `9 i& d
6 ~) N" R- \; t" T7 W4 F$ [
Flip Multidimensional Array5 q, R; U: o# X

# @' h4 U! {( d+ \Create a multidimensional array.3 U# d+ x$ P! m7 L3 B

/ Q9 ~: B/ S2 jA = cat(3, [1 2; 3 4], [5 6; 7 8])1 n8 r" X* s/ A/ ^9 j1 Y; g

) Q1 Z8 U8 A. A' S% MA = $ [2 `% B. w( T; Y
A(:,:,1) =* C9 k8 o$ Y! y/ {/ t

0 ?. B( o, u2 ^     1     20 J, b6 e6 I( K  ]" h4 k
     3     4
( {: _! ~' I3 H
# s% {$ O4 e. ^) N$ [* q4 K1 \
7 @6 N) s2 C3 ]7 i5 z2 p. RA(:,:,2) =
+ A! h' B" I- c/ j; h
" p' i2 X& y1 ]: Y     5     67 e$ K6 v5 F1 O  u/ X
     7     86 t% K6 }8 J/ i! d7 m# V
& q8 L! f6 O* G
A is an array of size 2-by-2-by-2.
+ H2 W, r9 F3 W0 E. B: r/ z) p
* d2 f: u. `( a8 H& v- XFlip the elements on each page of A in the horizontal direction.# W- V% M$ }) d

/ {% v' O  N* h/ CB = fliplr(A)% ^. S$ m6 N7 o& f8 w
. T, [: m( F6 v" F5 M+ K+ ]7 v
B = 6 `) ]  |. Z+ o7 J- b/ T
B(:,:,1) =  ?+ t, \5 x/ V1 b) M- _* j4 w

% D! N5 z8 b: Q4 T7 q     2     1* I( H1 A0 X4 ^; e
     4     3
9 W2 p2 c  e; G9 k3 X
! P/ b! \3 I7 B8 {1 [' B2 N' A- e
' o0 |9 I  W0 KB(:,:,2) =
3 i7 V3 s/ q+ `/ g( a4 w/ \; J* o% O) k; u
     6     5
5 ~, S' z- I2 U5 J     8     7" d8 B$ U) A8 R1 X2 w/ n

0 u) {& b" ?3 {/ R' r结果 B 与 A 的大小相同, 但元素的水平顺序被翻转。操作会单独翻转每个页面上的元素。" B1 N$ k" ~2 H3 A4 t3 j
9 y( \6 I- i9 ~" X
4 n& I3 A' v9 l7 W  O

该用户从未签到

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 02:47 , Processed in 0.125000 second(s), 23 queries , Gzip On.

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

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

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