mirror
result = flip(A, dim=1)
Input: A, dim · Output: result
What it is
Reverses row order (flipud, dim=1) or column order (fliplr/mirror, dim=2) of A, a Str, Vec, Mat, or Image. On a Str every spelling reverses the character order; on a plain Vec (which has no row/column orientation) both directions just reverse element order. dim (only meaningful for flip) is an optional keyword-or-positional scalar, 1 or 2, defaulting to 1.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = flip(A, dim=1) | A Str, Vec, Mat, or ImageReverses row order (flipud, dim=1) or column order (fliplr/mirror, dim=2) of A, a Str, Vec, Mat, or Image.dim scalar (default 1)dim (only meaningful for flip) is an optional keyword-or-positional scalar, 1 or 2, defaulting to 1. | result — | Returns the same type and shape as A. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
A = [1, 2, 3; 4, 5, 6]
x = 5
print("val={val(x)}")
print(transpose(A))
print("mirror={mirror([1, 2, 3])}")
val=5 [1, 4; 2, 5; 3, 6] mirror=[3, 2, 1]
from core-math
How it works
flipud(A)/fliplr(A) — reverse row order / column order. On a plain Vec (no row/column orientation of its own), both just reverse the element order — mirror is an alias for fliplr, the more common colloquial name for the same operation. flip(A, [dim=1]) picks between the two by MATLAB's own dimension numbering (dim=1 rows, dim=2 columns); on a Vec, dim is accepted but has no effect since there's only one axis to reverse either way.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.