再打flipud一次. flipud只需获取矩阵的每一列并反转顺序,以便最后一行显示.要撤消反转,请执行flipud已经反转的矩阵.反转矩阵的最后一行成为第一行,依此类推,因此您将获得原始订单.
注意:
>> A = rand(100,100);
>> B = isequal(A, flipud(flipud(A)))
B =
1
Run Code Online (Sandbox Code Playgroud)
A是一个随机的100 x 100矩阵.我曾经isequal确保原始矩阵等于该矩阵中每个元素的两次翻转矩阵.但是,如果你不想与这些名字混淆....如果你真的,真的,真的......我的意思是真的....想要一个能够"逆转"已经反转的矩阵的功能,你可以调用一个调用的函数flipdu来执行此翻转:
flipdu = @flipud;
Run Code Online (Sandbox Code Playgroud)
您可以定义辅助函数,向下翻转,以实现您的需求:
function [output] = flipdu(A)
%FLIPDU Flip array in down/up direction.
% OUTPUT = FLIPDU(A) returns A with the order of elements flipped upside down
% along the first dimension. For example,
%
% A = 1 4 becomes 3 6
% 2 5 2 5
% 3 6 1 4
%
% See also FLIPLR, ROT90, FLIP, FLIPUD.
output = flipud(A); % Equivalent to flip(A, 1)
end
Run Code Online (Sandbox Code Playgroud)