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

repelem — Repeat each element of an array by per-dimension replication factors, matching MATLAB repelem semantics.

repelem(A, r1, r2, ..., rN) repeats each element of A along the requested dimensions. Unlike repmat, which tiles whole arrays, repelem expands individual elements into repeated runs or blocks.

Syntax

B = repelem(A, R)
B = repelem(A, R1, R2, ...)

Inputs

A
Type
Any
Required
Yes
Description
Input array.
R
Type
Any
Required
Yes
Description
Scalar or vector replication control argument.
R1_RN
Type
Any
Required
Variadic
Description
Per-dimension scalar/vector replication controls.
NameTypeRequiredDefaultDescription
AAnyYes—Input array.
RAnyYes—Scalar or vector replication control argument.
R1_RNAnyVariadic—Per-dimension scalar/vector replication controls.

Returns

B
Type
Any
Description
Array with element-wise replication applied.
NameTypeDescription
BAnyArray with element-wise replication applied.

Errors

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

Behavior

repelem(v, n) repeats each element of a row or column vector v n times and preserves vector orientation.

repelem(v, counts) accepts a count vector with one non-negative integer count per element of v.

repelem(A, r1, r2, ..., rN) repeats matrix or N-D array elements along each dimension; scalar factors create element blocks and vector factors provide per-index counts for that dimension.

Numeric, logical, complex, string, char, and cell inputs are supported. Numeric, logical, complex, string, and cell arrays support N-D replication; char arrays are represented as 2-D character matrices.

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

Zero counts are allowed and remove the corresponding element or dimension slice from the output.

Replication counts must be finite, non-negative integers. Count vectors must match the size of the dimension they apply to.

The builtin checks shape and size overflow before materializing output arrays.

Execution and residency

GPU inputs and resident replication controls are gathered through their owning provider; the native-class host result is restored to the owning provider. No native replication hook is used.

This structural operation is a fusion boundary, not an elementwise or reduction kernel.

Examples

Repeating every element of a row vector

u = repelem([1 2 3], 2)

Expected output:

u =
     1     1     2     2     3     3

Using a per-element count vector

u = repelem([1 2 3], [1 2 3])

Expected output:

u =
     1     2     2     3     3     3

Expanding a matrix into element blocks

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

Expected output:

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

Dropping elements with zero counts

u = repelem([1 2 3 4 5], [0 1 0 2 1])

Expected output:

u =
     2     4     4     5

Repeating along a higher dimension

C = {1; 2};
D = repelem(reshape(C, [1 1 2]), 1, 1, 2);
size(D)

Expected output:

ans =
     1     1     4

Using repelem with coding agents

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

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

FAQ

How is repelem different from repmat?⌄

repmat tiles a whole array. repelem repeats each individual element, so matrix inputs expand into element-wise blocks.

Can counts be different for each element?⌄

Yes. In vector form, the count vector must have one entry for each vector element. In multi-dimensional form, a count vector applies to the dimension at the same argument position.

Are zero counts valid?⌄

Yes. A zero count omits that element or dimension index from the output.

Does repelem preserve row and column vector orientation?⌄

Yes. Row vectors remain row vectors, column vectors remain column vectors, including empty column vectors.

Does repelem run on the GPU?⌄

There is no native GPU replication hook. Resident data is gathered, replicated on the host, and restored with its original class and provider ownership.

Related Array functions

Shape

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

  • View the source for repelem 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
  • Repeating every element of a row vector
  • Using a per-element count vector
  • Expanding a matrix into element blocks
  • Dropping elements with zero counts
  • Repeating along a higher dimension
  • Using repelem with coding agents
  • FAQ
  • Related Array functions
  • Shape
  • Accumulation
  • Sorting Sets
  • Creation
  • Combinatorics
  • Binning
  • Indexing
  • Grouping
  • Introspection
  • Source you can read
  • About RunMat