RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

RunMat® is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
See all docs
Builtin Reference
    • blkdiag
    • cat
    • circshift
    • diag
    • flip
    • fliplr
    • flipud
    • horzcat
    • ipermute
    • kron
    • permute
    • repelem
    • repmat
    • reshape
    • rot90
    • shiftdim
    • squeeze
    • toeplitz
    • tril
    • triu
    • vertcat

fliplr — Flip arrays left-to-right in MATLAB and RunMat.

fliplr(A) reverses dimension 2, leaving other axes in place. Numeric, logical, complex, character, string, structure-array, and gpuArray paths are implemented; cell and object inputs are unsupported.

Syntax

B = fliplr(A)

Inputs

A
Type
Any
Required
Yes
Description
Input array/value to reverse along columns.
NameTypeRequiredDefaultDescription
AAnyYes—Input array/value to reverse along columns.

Returns

B
Type
Any
Description
Input array mirrored left-to-right (dimension 2).
NameTypeDescription
BAnyInput array mirrored left-to-right (dimension 2).

Errors

RunMat:fliplr:InvalidInput
When
Input type or conversion path is unsupported for fliplr.
Message
fliplr: invalid input argument
RunMat:fliplr:UnsupportedInput
When
Input type is unsupported for fliplr.
Message
fliplr: unsupported input type
IdentifierWhenMessage
RunMat:fliplr:InvalidInputInput type or conversion path is unsupported for fliplr.fliplr: invalid input argument
RunMat:fliplr:UnsupportedInputInput type is unsupported for fliplr.fliplr: unsupported input type

Behavior and placement

Always reverses dimension 2 (columns) and leaves all other dimensions untouched, even for rank > 2 data.

Inputs with fewer than two columns (column vectors, scalars) are returned unchanged because the second dimension is singleton.

Logical, numeric, complex, character, and string arrays preserve their types and full N-D shapes. All eight integer classes preserve authoritative values and class.

Dimensions larger than ndims(A) are treated as singleton axes, so fliplr never errors when A has rank < 2.

Numeric reordering preserves native single, double, logical, complex, and all eight integer storage classes where supported. Structure arrays are reordered by their owning structural path; cell arrays are supported only by flipud.

Explicit gpuArray inputs remain with their exact owner when the provider can execute or restore the result; automatic device placement may restore to host. Controls are validated before provider effects.

GPU execution and fusion

The resident route uses the owning provider's flip hook on zero-based axis 1 where supported. Other classes use an exact owner-controlled gather and upload fallback. This is a structural fusion boundary.

Examples

Reverse Columns of a Matrix

A = [1 2 3; 4 5 6];
B = fliplr(A)

Expected output:

B =
     3     2     1
     6     5     4

Mirror an Image Matrix Horizontally

img = reshape(1:16, 4, 4);
mirrored = fliplr(img)

Expected output:

mirrored =
    13     9     5     1
    14    10     6     2
    15    11     7     3
    16    12     8     4

Flip the Order of Polynomial Coefficients

c = [1 0 -2 5];
rev = fliplr(c)

Expected output:

rev = [5  -2  0  1]

Reverse Each Slice in a 3-D Array Along Columns

T = reshape(1:24, [3 4 2]);
F = fliplr(T)

Expected output:

F(:,:,1) =
    10     7     4     1
    11     8     5     2
    12     9     6     3

F(:,:,2) =
    22    19    16    13
    23    20    17    14
    24    21    18    15

Preserve Column Vector Orientation

col = (1:4)';
same = fliplr(col)

Expected output:

same =
     1
     2
     3
     4

Flip Characters in a Two-Row Char Array

C = ['r','u','n'; 'm','a','t'];
Ct = fliplr(C)

Expected output:

Ct =
    'nur'
    'tam'

Keep gpuArray Results on the Device While Flipping Columns

G = gpuArray(rand(8, 8));
H = fliplr(G)

Using fliplr with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how fliplr changes the result.

Run a small fliplr example, explain the result, then change one input and compare the output.

FAQ

Does fliplr change column vectors?⌄

No. A column vector has a singleton second dimension, so reversing that axis leaves the data unchanged.

Is fliplr the same as calling flip(A, 2)?⌄

Yes. fliplr is a convenience wrapper around flip that always targets dimension 2 (columns).

Can I apply fliplr to N-D tensors?⌄

Absolutely. Only dimension 2 is reversed; all other axes keep their original order regardless of rank.

Does fliplr support string and character arrays?⌄

Yes. String arrays reorder their elements, and character arrays mirror each row while preserving their character storage.

What happens on the GPU if there is no flip kernel?⌄

RunMat gathers the tensor once, mirrors it on the CPU, and uploads the result so you still receive a gpuArray.

Does fliplr allocate new GPU buffers?⌄

The resident route validates an independent output handle; the owning provider determines the physical backing. The input is not modified.

Is fliplr numerically stable?⌄

Yes. The function only reorders elements; values are never modified, so it is numerically stable.

Related Array functions

Shape

blkdiag · cat · circshift · diag · flip · flipud · horzcat · ipermute · kron · permute · repelem · repmat · reshape · rot90 · shiftdim · squeeze · toeplitz · tril · triu · vertcat

Accumulation

accumarray

Sorting Sets

argsort · intersect · ismember · ismembertol · issorted · issortedrows · setdiff · setxor · sort · sortrows · union · unique

Creation

colon · createArray · empty · eye · false · full · inf · int16.empty · int32.empty · int64.empty · int8.empty · linspace · logspace · magic · meshgrid · nan · ndgrid · nonzeros · ones · peaks · rand · randi · randn · randperm · range · sparse · spdiags · speye · spones · sprand · true · uint16.empty · uint32.empty · uint64.empty · uint8.empty · zeros

Combinatorics

combinations · nchoosek · perms

Binning

discretize

Indexing

find · ind2sub · sub2ind

Grouping

findgroups · groupcounts · grp2idx · splitapply

Introspection

height · iscolumn · isempty · ismatrix · isrow · isscalar · isvector · length · ndims · numel · size · width

Source you can read

Every RunMat function's source is public. Read exactly how fliplr is executed, line by line, in Rust.

  • View the source for fliplr in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • Behavior and placement
  • GPU execution and fusion
  • Examples
  • Reverse Columns of a Matrix
  • Mirror an Image Matrix Horizontally
  • Flip the Order of Polynomial Coefficients
  • Reverse Each Slice in a 3-D Array Along Columns
  • Preserve Column Vector Orientation
  • Flip Characters in a Two-Row Char Array
  • Keep gpuArray Results on the Device While Flipping Columns
  • Using fliplr with coding agents
  • FAQ
  • Related Array functions
  • Shape
  • Accumulation
  • Sorting Sets
  • Creation
  • Combinatorics
  • Binning
  • Indexing
  • Grouping
  • Introspection
  • Source you can read
  • About RunMat