【 MATLAB 】fliplr 函数介绍(从左到右翻转阵列)
fliplr
Flip array left to right
Syntax
B = fliplr(A)
Description
B = fliplr(
returns A
)A
with its columns flipped in the left-right direction (that is, about a vertical axis).
B = fliplr (a) 返回 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.
如果 a 是行向量, 则 fliplr (a) 返回与其元素的顺序反转的相同长度的向量。如果 a 是列向量, 则 fliplr (a) 只是返回 a。对于多维数组, fliplr 在由第一个和第二个维度形成的平面上运行。
Flip Row Vector
Create a row vector.
A = 1:10
A = 1×10 1 2 3 4 5 6 7 8 9 10
Use fliplr
to flip the elements of A
in the horizontal direction.
B = fliplr(A)
B = 1×10 10 9 8 7 6 5 4 3 2 1
The order of the elements in B
is reversed compared to A
.
Flip Cell Array of Characters
Create a 3-by-3 cell array of characters.
A = {'a' 'b' 'c'; 'd' 'e' 'f'; 'g' 'h' 'i'}
A = 3x3 cell array {'a'} {'b'} {'c'} {'d'} {'e'} {'f'} {'g'} {'h'} {'i'}
Change the order of the columns in the horizontal direction by using fliplr
.
B = fliplr(A)
B = 3x3 cell array {'c'} {'b'} {'a'} {'f'} {'e'} {'d'} {'i'} {'h'} {'g'}
The order of the first and third columns of A
is switched in B
, while the second column remains unchanged.
Flip Multidimensional Array
Create a multidimensional array.
A = cat(3, [1 2; 3 4], [5 6; 7 8])
A = A(:,:,1) = 1 2 3 4 A(:,:,2) = 5 6 7 8
A
is an array of size 2-by-2-by-2.
Flip the elements on each page of A
in the horizontal direction.
B = fliplr(A)
B = B(:,:,1) = 2 1 4 3 B(:,:,2) = 6 5 8 7
结果 B 与 A 的大小相同, 但元素的水平顺序被翻转。操作会单独翻转每个页面上的元素。
文章来源: reborn.blog.csdn.net,作者:李锐博恩,版权归原作者所有,如需转载,请联系作者。
原文链接:reborn.blog.csdn.net/article/details/83244916
- 点赞
- 收藏
- 关注作者
评论(0)