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

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

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x

# |$ g* G1 u3 |* l) O! |' q" Pfliplr% A- m" A, W. Q7 K; P
Flip array left to right
! ?% E" h* p' u: |6 C* K- M( \6 u! [/ e" {/ T3 _0 F
  H" u1 m* E8 O) d2 E3 [( S2 M
Syntax6 |! L2 ~/ N6 X

; o: w1 b8 q* {& ]9 JB = fliplr(A)
1 ]% D# h8 p8 U3 V" t% a& N
4 j  P4 J+ W4 V: m; `0 f( w& \( S1 Y# l
Description

& ?6 f7 k3 e3 f1 h; Q, m2 i8 B7 c+ ~0 T# p, j: ^9 M
B = fliplr(A) returns A with its columns flipped in the left-right direction (that is, about a vertical axis).
+ g  U8 P( x" U. Z9 e! X0 ?3 r' o$ J) X: u7 I
B = fliplr (a) 返回 A, 其列在左右方向 (即关于垂直轴) 反转。$ k  l8 W8 c: `( r* @* ?; N
4 b/ |9 J8 D' R2 M; `& 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.4 x5 B0 c& A/ Z( m/ j

- P" U9 t9 l% K( T3 b0 j2 a, p如果 a 是行向量, 则 fliplr (a) 返回与其元素的顺序反转的相同长度的向量。如果 a 是列向量, 则 fliplr (a) 只是返回 a。对于多维数组, fliplr 在由第一个和第二个维度形成的平面上运行。% Y* o6 W) z: v6 d# b
; H5 r! m  x5 H1 P/ D7 e/ v

7 E% F0 D* L; K6 X- D& i2 xFlip Row Vector
: D% l3 N- E( n' n$ w. B
8 F/ S! Y1 Q2 U8 E  ^$ H4 H, W" cCreate a row vector.
* y- _- U! F  G  b
. G+ h$ U3 {# E- o9 JA = 1:10
) n! e( `- t+ J( a9 V; N6 M! w0 L; [. t7 o5 u9 _6 o5 Y$ E
A = 1×10
- z. Y/ h3 A; m- O$ B9 l
3 c  G# H+ O2 E- r     1     2     3     4     5     6     7     8     9    10+ a# g2 _& M5 F8 |' J) G
' b& q2 P+ K" k3 c5 C
Use fliplr to flip the elements of A in the horizontal direction.
4 c" `/ S( y" V* d
0 r' m7 i0 r5 O& LB = fliplr(A)
9 j6 P. @* g- t7 w' C% x3 p7 Z5 f9 ~- _& S7 k9 @8 X
B = 1×10
- A8 b3 k0 [/ ~% n4 \0 V
1 A2 N2 d2 L5 A- y" T! c+ R3 u7 n    10     9     8     7     6     5     4     3     2     1
. Y* M, D3 [9 h, N! f9 A3 b0 g. C
The order of the elements in B is reversed compared to A.8 c5 P: S$ `2 y0 T4 E

; X; O; [: v+ }) d$ o9 ]( a8 S) N7 Z5 Q' H$ o
Flip Cell Array of Characters
( ^4 X6 H6 Z7 O! W; u
; K5 F- @. o% Z! R
' z* K: O7 c( r8 C. p$ z4 N& Y# [+ [1 UCreate a 3-by-3 cell array of characters.
' `" {5 U# {; m8 |  ]6 x+ N; R
6 G& p, t/ X) B+ v8 z4 ~A = {'a' 'b' 'c'; 'd' 'e' 'f'; 'g' 'h' 'i'}0 B) m3 P0 b* ^1 m% q5 V3 x( f

! U/ N) s, l3 B& x# q' l) lA = 3x3 cell array# K/ j% h, y& r/ U& h
    {'a'}    {'b'}    {'c'}
1 T+ |9 L$ D; u3 F" ^  c9 m    {'d'}    {'e'}    {'f'}* j' G1 e7 z6 A1 E
    {'g'}    {'h'}    {'i'}$ f7 f" X' l* K0 [
: l) j5 S2 l& I+ W; h( K
Change the order of the columns in the horizontal direction by using fliplr.
. m4 z: g" Z4 F2 ^
( J. K. {8 d; e5 m' c- L. {B = fliplr(A)
; M  T# G6 H% k3 l
/ _( ^* T8 R# j' g9 ~- O$ a; QB = 3x3 cell array& y4 X: }7 Y. h6 X6 V! `! H# ]
    {'c'}    {'b'}    {'a'}
4 z1 o) O" o3 d( h% u+ f8 i3 c' h    {'f'}    {'e'}    {'d'}2 B$ \/ `( r) w# q
    {'i'}    {'h'}    {'g'}
- x# l6 c# R- [9 p* F7 _9 y" `1 Y, o# ?
The order of the first and third columns of A is switched in B, while the second column remains unchanged.
; ~' A: p5 E6 `1 u7 n$ g+ E4 ~. \; Y: V5 u" e$ D8 L

& E; S0 f+ k. VFlip Multidimensional Array
) R8 S, Z" i  c/ c- C. r( v& o! P. ]- n+ b- M
Create a multidimensional array.
/ t  R. W4 S! `1 ~0 u" h, d) O3 E
' T9 F( }4 D: g' \  k! V9 LA = cat(3, [1 2; 3 4], [5 6; 7 8])2 y0 ~% `9 o/ @( }; L

0 \; o. p) _2 J% r# n3 ]% s8 ?A =
# f" P1 B# X6 K+ u# BA(:,:,1) =5 i9 b+ g# y& J# G: F
# `( k; W: N" H8 Q6 C7 _) P
     1     2' `3 P; @- |0 ]
     3     4
5 u: w/ ^! {3 o
2 R( U2 _  Y; R; T' a% |( G# T
4 J4 `8 c6 l) qA(:,:,2) =6 k2 h5 p, e1 d1 o
  q+ i. k3 ~$ q; ~3 Q
     5     6
# P- t2 S* J( {' l2 w2 Z2 q     7     8
* R7 N0 x7 {6 V! L& h5 n3 s! @4 S8 @# w+ R0 l
A is an array of size 2-by-2-by-2.- e0 H  r; R. v! {- y

4 d$ |* P5 e; O3 X" y5 Y" DFlip the elements on each page of A in the horizontal direction.& r% Y8 W5 Z' j0 K& A

0 h# l' @4 c. U' W6 g" x6 GB = fliplr(A)
1 i6 c1 M, F- y( X; q4 I
2 l* b# g# ~; t0 M3 m9 rB =
6 A5 b3 g' T; B: l* Y: j4 zB(:,:,1) =
5 V/ L7 n- l& n& B) N7 X, X' _  ?4 y; K) j6 g. d+ {+ \
     2     1# l" R1 f: S& v6 i
     4     3/ W$ |7 @" N% M9 @
- ]) P' [0 A4 R& [8 o# g- B

3 R6 m/ g+ S0 OB(:,:,2) =
+ P% @, {! ?0 s3 x8 h% O" R3 Y. Z; N: y. L& u7 w  V
     6     5
! T' X6 B3 w7 }  H* s, K     8     7
& a7 Z6 }+ U/ H* F
4 {' Q2 ^% U( l  H) G- [; x结果 B 与 A 的大小相同, 但元素的水平顺序被翻转。操作会单独翻转每个页面上的元素。) y$ m  ?2 U0 C6 Q7 X* B

4 o/ L  S. s" D) S% p8 }7 F
: K  C5 V2 x# o0 m6 g/ ]0 x' w

该用户从未签到

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

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

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

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