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

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

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x
2 o( V7 F1 Y% ~
fliplr/ k+ v9 ]3 `$ K3 _# I
Flip array left to right$ ~, o6 W8 B0 R+ h; i  O0 I/ J& c$ m

( J0 B5 n$ E( q4 z
6 {6 L0 O* O) |& Q9 R# QSyntax
3 S' j6 e% b4 G" P  x3 H
5 e5 A1 P* d. l: BB = fliplr(A)
' C0 `! Y- @5 U" S2 n9 {- S, {$ z$ E9 m+ k: e9 ~) e
) |1 k3 i( m0 K; G- w
Description

1 h! W5 O$ ~$ c9 M+ [: u1 h4 {; S, B! D" {0 P: w6 G3 K' c  `
B = fliplr(A) returns A with its columns flipped in the left-right direction (that is, about a vertical axis).
- x. m" z0 G# y! N; m* M: \' k* l  }2 A8 {; z* o/ z" R4 v
B = fliplr (a) 返回 A, 其列在左右方向 (即关于垂直轴) 反转。
- ]9 _- ?% ?6 d" y
3 E( O0 a( X1 F  Z) 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.4 n$ b1 x, w6 D6 [

6 |" E. b8 U" h如果 a 是行向量, 则 fliplr (a) 返回与其元素的顺序反转的相同长度的向量。如果 a 是列向量, 则 fliplr (a) 只是返回 a。对于多维数组, fliplr 在由第一个和第二个维度形成的平面上运行。3 \: S" z* N5 I. C5 N) \
7 X3 \# [+ F- K: r& o/ V1 x8 O. l* t: x

  f7 l" s0 l% i& _; lFlip Row Vector! R9 ~/ g4 I* @0 Z) U: ?
0 W. @) b. U8 D) r4 E
Create a row vector.
  _" j3 m. ?" h; i' S
% x! \, s6 M" m! h4 ]- |A = 1:10$ O0 J  D1 G4 g# X4 f9 R( J
! c5 T7 J& T4 C+ h, c
A = 1×100 O; Z5 c8 b& U8 _! s2 ]
9 V# L. u. |4 @% B
     1     2     3     4     5     6     7     8     9    10
* S% k! W. [' S9 C: d' z5 q( j4 R( P; \
Use fliplr to flip the elements of A in the horizontal direction." r8 M* p  q" E

( E4 D& R+ g' o) [/ z1 P: [0 fB = fliplr(A)
, V! z  `: a1 d3 k0 t8 V* ^
3 z, H8 Q  j( R4 fB = 1×10
2 a$ f" r! |2 P) P( }( K$ E" p# x/ U
    10     9     8     7     6     5     4     3     2     1# p% x/ n) |3 U: `7 U

+ c' P& H, Z2 A$ P4 p) L3 q& q1 a, FThe order of the elements in B is reversed compared to A./ M' S0 k/ K- _" h4 E* b9 q3 x# J
+ F6 z7 k& q! T

/ q$ t- I( l) @+ E/ g/ U9 `Flip Cell Array of Characters
8 b) T& ~+ a" t! C6 q- j5 s& z- `, |) ^# L4 b+ d

% @" _/ `" a& iCreate a 3-by-3 cell array of characters." |/ e- z( A) z0 L$ Q2 b, H+ q1 x1 I

5 @* ]1 t- ?, `0 I8 M' _# `A = {'a' 'b' 'c'; 'd' 'e' 'f'; 'g' 'h' 'i'}
& ^: f3 [0 r' c! [* F! y0 g( y6 v4 A& u( _, j9 [2 T
A = 3x3 cell array
, X* k5 F/ W. i. h    {'a'}    {'b'}    {'c'}4 y1 i3 S" i% L" X8 X" ]$ }* t1 {
    {'d'}    {'e'}    {'f'}
6 t# e; B& t& C) z9 ~8 Z, S    {'g'}    {'h'}    {'i'}5 }; O; o5 v- L/ r% i) r
+ @( B5 I) x( K, k, Q) F' U0 \) F
Change the order of the columns in the horizontal direction by using fliplr.
. Z" @+ A9 P% E* f
1 O6 R( r' i5 G' q$ `& E& BB = fliplr(A)
" P, ~5 o3 m7 W9 I  W! M6 X$ {- o  M1 [1 D- _! x
B = 3x3 cell array0 `8 v3 ^( ]% Z, T& E9 j
    {'c'}    {'b'}    {'a'}
# T+ Z: D2 r3 p# [' _" f    {'f'}    {'e'}    {'d'}
* i  b4 D( e: m4 j9 u    {'i'}    {'h'}    {'g'}7 q# w& X) Z. j% c4 l1 z
7 \: B/ A2 G. X9 @
The order of the first and third columns of A is switched in B, while the second column remains unchanged.% W( W3 U5 D+ w" w6 x" J
- c+ q; _/ q: H5 h
3 X' w# D- ~3 c: w7 h
Flip Multidimensional Array6 g; h  B( U% L4 D

1 p3 k$ i# a- u' nCreate a multidimensional array.
. Q% y4 h3 J! {7 s! h+ w$ w1 U* O2 Y' }  W! x' h( Y3 Z" P- L
A = cat(3, [1 2; 3 4], [5 6; 7 8])! L% f  b$ i7 i7 o8 v( G. v8 K
3 Z. G( U/ {+ n+ `$ U! [* i
A = / T/ q! U3 E0 X0 @8 ^% d
A(:,:,1) =
& ^: D9 c- I8 N7 `/ }
6 r9 [% f8 |/ p3 q+ k. p     1     2( W% r- O5 O% z9 e: f
     3     4$ r- {# K+ L+ W, U1 B- D. ~; _9 \

  M) A  H- j! u! N. {, y2 U: \! [6 o- W. t4 N( T! P5 ^  K
A(:,:,2) =
* ^+ H4 g7 Y+ n+ X  U8 b) ]7 Z- K3 m  _8 k7 ^' i' l
     5     6  ]& H2 \2 k, _+ W) R+ t9 G
     7     8
( k, [0 M# r8 N- y
0 V9 h/ _3 B8 q% G/ V! ^3 K$ HA is an array of size 2-by-2-by-2.
5 k5 A# r0 ]5 v- s: ?3 N- O; R7 Z/ j* v1 G& ?( E! ^9 F
Flip the elements on each page of A in the horizontal direction.
( B9 C7 S/ N7 \9 S. k2 G0 N5 b# T0 f7 ^  W& J3 M/ @+ p
B = fliplr(A)6 C- Q0 m1 J7 E& V( W

, ?& |: i, ?3 x+ w5 N: _3 D) dB =
( ?" t6 _) }, `B(:,:,1) =( n6 ^: ?& G5 i- K
7 u. I$ s* F/ s! W9 O- C3 a
     2     1
4 q. C0 b3 I/ g  M1 d. ?. `     4     3
" Y2 q: x  G$ n! _& X
* L0 z( d1 g' w; B5 y: E
2 t, ]- Z% x9 m. AB(:,:,2) =. h; h" h. g/ U6 M2 A
) H2 A2 @9 p! }& p
     6     5
& L* d5 e7 l& U' t     8     7
- l+ Z! Z  z1 i: p- S, C6 F, h* M) ?% ^. O" s. U
结果 B 与 A 的大小相同, 但元素的水平顺序被翻转。操作会单独翻转每个页面上的元素。! J( t8 W2 T3 f* G3 N, F/ K) Q

% H& e8 w/ |6 k1 t, x2 j6 d4 W5 y& e( `8 X# W9 y. ]" 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-10-5 21:19 , Processed in 0.125000 second(s), 24 queries , Gzip On.

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

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

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