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

repmat — Tile arrays across one or more dimensions using MATLAB-compatible repmat rules.

repmat(A, reps) tiles A according to replication factors in reps. It follows MATLAB-compatible shape rules and supports numeric, logical, char, string, cell, and GPU-backed array inputs.

Syntax

B = repmat(A, r)
B = repmat(A, m, n)
B = repmat(A, d1, d2, ...)

Inputs

A
Type
Any
Required
Yes
Description
Input array to replicate.
r
Type
Any
Required
Yes
Description
Replication vector or scalar factor.
m
Type
NumericScalar
Required
Yes
Description
Row replication factor.
n
Type
NumericScalar
Required
Yes
Description
Column replication factor.
dims
Type
NumericScalar
Required
Variadic
Description
Per-dimension replication factors.
NameTypeRequiredDefaultDescription
AAnyYes—Input array to replicate.
rAnyYes—Replication vector or scalar factor.
mNumericScalarYes—Row replication factor.
nNumericScalarYes—Column replication factor.
dimsNumericScalarVariadic—Per-dimension replication factors.

Returns

B
Type
Any
Description
Replicated array tiled by requested replication factors.
NameTypeDescription
BAnyReplicated array tiled by requested replication factors.

Errors

RunMat:repmat:MissingReplicationFactors
When
No replication factors are provided.
Message
repmat: replication factors must be specified
RunMat:repmat:InvalidReplicationFactors
When
Replication factors are non-scalar, non-integer, negative, or otherwise invalid.
Message
repmat: invalid replication factors
RunMat:repmat:UnsupportedInput
When
Input type is unsupported for repmat.
Message
repmat: unsupported input type
RunMat:repmat:Internal
When
Internal allocation/indexing/provider path fails.
Message
repmat: internal operation failed
IdentifierWhenMessage
RunMat:repmat:MissingReplicationFactorsNo replication factors are provided.repmat: replication factors must be specified
RunMat:repmat:InvalidReplicationFactorsReplication factors are non-scalar, non-integer, negative, or otherwise invalid.repmat: invalid replication factors
RunMat:repmat:UnsupportedInputInput type is unsupported for repmat.repmat: unsupported input type
RunMat:repmat:InternalInternal allocation/indexing/provider path fails.repmat: internal operation failed

Behavior

repmat(A, m, n) or repmat(A, [m n]) repeats A m times along rows and n times along columns.

A size vector [r1 r2 … rN] can be given as a row or column; trailing dimensions default to 1, letting you replicate only the axes you care about.

Supplying a scalar replication factor (e.g., repmat(A, k)) duplicates non-structure inputs across every stored dimension, ensuring at least the first two dimensions are replicated. Structure arrays retain their existing per-axis rule: the supplied factor applies to the first axis and omitted factors default to one.

Zero replication factors produce empty dimensions; repmat(A, 0, 3) has shape [0, 3*size(A,2)].

Character and cell arrays use row/column tiling with trailing factors at most one; numeric, logical, complex, string, and structure arrays use their existing N-D tiling paths.

Replication factors must be finite, non-negative integers; RunMat raises descriptive errors for negative, fractional, or excessively large sizes.

All eight integer data classes are tiled from authoritative native storage and returned in the same class; typed integer replication factors are decoded structurally without a floating round trip.

Admitted provider tiling keeps the result on the device. A host fallback tiles exact-class values and attempts restoration through the input's owning provider. Explicit gpuArray input cannot silently produce a host result; automatically placed floating-point values may remain on the host when restoration upload is unsupported.

Execution and residency

The runtime uses admitted provider tiling or exact-class host tiling restored to the owning provider. Operational or unphased provider errors are propagated without replay.

You usually do not need to call gpuArray directly. RunMat's planner keeps values on the GPU when it detects that further operations benefit from staying there. Explicit gpuArray calls remain available for compatibility with legacy MATLAB code and when you want to steer residency manually.

Structural data retains its admitted single, double, logical, or native signed/unsigned integer storage, including supported complex arrays. This does not upgrade preceding numerical accuracy or authorize an unsupported carrier.

The first argument is the data operand; remaining arguments, where present, are dimension or order controls. No scalar broadcasting, elementwise/reduction fusion template, or standalone fusion constant ABI is declared.

Examples

Tiling a matrix across rows and columns

A = [1 2; 3 4];
B = repmat(A, 2, 3)

Expected output:

B =
     1     2     1     2     1     2
     3     4     3     4     3     4
     1     2     1     2     1     2
     3     4     3     4     3     4

Using a scalar replication factor

row = 1:4;
Tiled = repmat(row, 3);
size(Tiled)

Expected output:

ans =
     3    12

Replicating into three dimensions

A = reshape(1:6, [1 3 2]);
T = repmat(A, [2 1 4]);
size(T)

Expected output:

ans =
     2     3     8

Repeating logical masks with zero dimensions

mask = logical([1 0 1]);
emptyMask = repmat(mask, 0, 3);
size(emptyMask)

Expected output:

ans =
     0     9

Replicating string scalars into string arrays

name = "runmat";
names = repmat(name, 2, 2)

Expected output:

names =
  2x2 string array
    "runmat"    "runmat"
    "runmat"    "runmat"

Replicating data that lives on the GPU

G = gpuArray(magic(3));
T = repmat(G, [2 1]);
result = gather(T)

Using repmat with coding agents

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

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

FAQ

Are replication factors required to be integers?⌄

Yes. RunMat follows MATLAB and requires every replication factor to be a non-negative integer. Non-integers raise the descriptive error repmat: replication factor <n> must be an integer.

What happens when I pass a scalar replication factor?⌄

For non-structure inputs, RunMat duplicates every stored dimension, ensuring at least the first two dimensions receive the factor. For structure arrays, the factor applies to the first axis and omitted factors default to one.

Can I request zero replication along a dimension?⌄

Yes. Zero factors produce empty dimensions while preserving the remaining sizes, which is useful when constructing placeholder tensors or short-circuiting loops.

Does repmat work with char, string, or cell arrays?⌄

Yes. Character and cell arrays tile rows and columns with trailing factors at most one. String, numeric, logical, complex, and structure arrays use their existing N-D replication paths.

How does repmat handle GPU tensors today?⌄

Device tiling preserves residency. An admitted host fallback attempts exact-owner restoration; explicit gpuArray intent forbids silent host publication, while automatically placed floating-point values may remain on the host when upload is unsupported.

Does the result reuse backing storage from the input?⌄

No. repmat always creates a new array so modifying the result never mutates the original input.

Can replication overflow memory?⌄

RunMat checks for overflow when multiplying shape dimensions. If the requested size cannot fit in native address space, the builtin raises a descriptive error before attempting allocation.

Does repmat preserve data ordering?⌄

Yes. Column-major ordering is maintained for numeric, logical, string, and complex arrays, while char and cell arrays respect their row-major storage conventions within RunMat.

Related Array functions

Shape

blkdiag · cat · circshift · diag · flip · fliplr · flipud · horzcat · ipermute · kron · permute · repelem · 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 repmat is executed, line by line, in Rust.

  • View the source for repmat 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
  • Execution and residency
  • Examples
  • Tiling a matrix across rows and columns
  • Using a scalar replication factor
  • Replicating into three dimensions
  • Repeating logical masks with zero dimensions
  • Replicating string scalars into string arrays
  • Replicating data that lives on the GPU
  • Using repmat with coding agents
  • FAQ
  • Related Array functions
  • Shape
  • Accumulation
  • Sorting Sets
  • Creation
  • Combinatorics
  • Binning
  • Indexing
  • Grouping
  • Introspection
  • Source you can read
  • About RunMat