RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact
  • License
  • Privacy

Learn

  • Docs
  • Blog
  • Benchmarks
  • RunMat vs MATLAB Online

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

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
    • colon
    • createArray
    • empty
    • eye
    • false
    • full
    • inf
    • linspace
    • logspace
    • magic
    • meshgrid
    • nan
    • nchoosek
    • ndgrid
    • nonzeros
    • ones
    • peaks
    • perms
    • rand
    • randi
    • randn
    • randperm
    • range
    • sparse
    • spdiags
    • speye
    • spones
    • sprand
    • true
    • zeros

createArray — Create an array of a specified class and value.

createArray accepts dimensions first, followed by an optional class name and Like or FillValue name-value arguments. Integer dimensions are structural and exact. Integer FillValue and Like forms preserve authoritative class, complexity, and resident storage. The result is complex when either Like or FillValue is complex.

Syntax

X = createArray(sz1, ..., szN, classname?, Like=prototype?, FillValue=value?)

Inputs

NameTypeRequiredDefaultDescription
argumentsAnyVariadic—Dimensions, optional class name, and Like/FillValue name-value arguments.

Returns

NameTypeDescription
AAnyConstant-valued output array.

Errors

IdentifierWhenMessage
—The fill value is not scalar.createArray: FillValue must be a scalar
—The fill value type is unsupported.createArray: unsupported FillValue type
—The 'like' keyword is provided without a prototype argument.createArray: Like requires a prototype
—The 'like' keyword is provided multiple times.createArray: Like may be specified only once
—A class keyword and a 'like' prototype are both provided.createArray: classname and Like cannot be combined
—An unsupported output class is requested.createArray: unsupported class
—A trailing option string is not recognized.createArray: unrecognized option
—Dimension arguments fail numeric/shape parsing.createArray: dimensions must be integer values

How createArray works

  • createArray returns scalar double zero.
  • createArray(n) creates an n-by-n array and createArray(m,n,...) creates the requested shape.
  • Negative dimensions are treated as zero.
  • A trailing class name selects the output class.
  • FillValue selects the repeated scalar value and preserves its class unless classname or Like requests assignment conversion. Without Like, a GPU-resident FillValue contributes residency and owning provider but does not override an explicit classname.
  • Like preserves numeric class and GPU residency; classname and Like cannot be combined.
  • If either Like or FillValue is complex, the output is complex. A real single Like therefore produces complex single for a complex FillValue, while a real double Like produces complex double.

Examples

Integer array

A = createArray(2,3,'uint64',FillValue=uint64(7));

Expected output:

2-by-3 uint64 array of sevens

Prototype

A = createArray(2,3,Like=uint16(1),FillValue=8);

Expected output:

2-by-3 uint16 array

Complex FillValue with a real prototype

A = createArray(2,Like=single(0),FillValue=1+2i);

Expected output:

2-by-2 complex single array

Using createArray with coding agents

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

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

FAQ

How is createArray different from fill?⌄

createArray constructs arrays; fill creates 2-D Patch graphics.

Related Array functions

Creation

colon · empty · eye · false · full · inf · linspace · logspace · magic · meshgrid · nan · nchoosek · ndgrid · nonzeros · ones · peaks · perms · rand · randi · randn · randperm · range · sparse · spdiags · speye · spones · sprand · true · zeros

Grouping

accumarray · combinations · discretize · findgroups · groupcounts · grp2idx · splitapply

Sorting Sets

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

Shape

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

Indexing

find · ind2sub · sub2ind

Introspection

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

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how createArray is executed, line by line, in Rust.

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

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 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
  • How createArray works
  • Examples
  • Integer array
  • Prototype
  • Complex FillValue with a real prototype
  • Using createArray with coding agents
  • FAQ
  • Related Array functions
  • Creation
  • Grouping
  • Sorting Sets
  • Shape
  • Indexing
  • Introspection
  • Open-source implementation
  • About RunMat