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
    • height
    • iscolumn
    • isempty
    • ismatrix
    • isrow
    • isscalar
    • isvector
    • length
    • ndims
    • numel
    • size
    • width

width — Return the number of table variables or array columns.

width reads a table variable count or the second visible array dimension from validated metadata and returns an exact host double scalar.

Syntax

n = width(A)

Inputs

A
Type
Any
Required
Yes
Description
Value whose MATLAB-visible dimensions are inspected.
NameTypeRequiredDefaultDescription
AAnyYes—Value whose MATLAB-visible dimensions are inspected.

Returns

n
Type
NumericScalar
Description
Exact table-variable count or second MATLAB-visible dimension extent.
NameTypeDescription
nNumericScalarExact table-variable count or second MATLAB-visible dimension extent.

Errors

RunMat:width:ResultNotExactDouble
When
The variable or column count cannot be represented exactly by the documented double output.
Message
width: result exceeds exact double range
RunMat:width:InternalError
When
Value, tabular, resident, or distributed shape metadata is invalid.
Message
width: invalid shape metadata
RunMat:width:TooManyOutputs
When
More than one output is requested.
Message
width: too many output arguments
IdentifierWhenMessage
RunMat:width:ResultNotExactDoubleThe variable or column count cannot be represented exactly by the documented double output.width: result exceeds exact double range
RunMat:width:InternalErrorValue, tabular, resident, or distributed shape metadata is invalid.width: invalid shape metadata
RunMat:width:TooManyOutputsMore than one output is requested.width: too many output arguments

Variables in tables and columns in arrays

width(A) returns a table's variable count or an ordinary array's second MATLAB-visible dimension as a host double scalar. For ordinary arrays, width(A) is equivalent to size(A, 2).

Each table variable counts once even when that variable stores a matrix with several columns. Numeric, complex, logical, character, string, cell, datetime, duration, categorical, sparse, and object arrays use their outer column count.

Structural metadata

All eight fixed-width integer classes use the same structural path. Their payloads are not converted or inspected. Empty arrays preserve their second-dimension extent.

gpuArray and distributed inputs use validated handle metadata. width launches no kernel, calls no acceleration provider, and transfers no payload. The result is returned on the host at a fusion boundary.

RunMat reports an error if the variable or column count cannot be represented exactly by the documented double result instead of rounding the structural value.

Examples

Count array columns

A = zeros(3, 5, 'uint16');
n = width(A)

Expected output:

n = 5

Count table variables

samples = [1 2; 3 4; 5 6];
label = [10; 20; 30];
T = table(samples, label);
n = width(T)

Expected output:

n = 2

Preserve an empty array's column count

A = zeros(0, 7);
n = width(A)

Expected output:

n = 7

Read a resident column count

G = gpuArray(ones(4, 256));
n = width(G)

Expected output:

n = 256

Using width with coding agents

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

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

FAQ

How is width related to size?⌄

For ordinary arrays, width(A) returns the same count as size(A, 2). For tables and timetables, it returns the number of variables.

How is a matrix-valued table variable counted?⌄

It counts as one table variable. The columns inside that variable do not increase table width.

Does width gather a gpuArray?⌄

No. RunMat reads the second dimension from resident shape metadata.

Where does the result live?⌄

The result is a host double scalar because it describes shape metadata rather than array payload.

Related Array functions

Introspection

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

Accumulation

accumarray

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 · shiftdim · squeeze · toeplitz · tril · triu · vertcat

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

Source you can read

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

  • View the source for width 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
  • Variables in tables and columns in arrays
  • Structural metadata
  • Examples
  • Count array columns
  • Count table variables
  • Preserve an empty array's column count
  • Read a resident column count
  • Using width with coding agents
  • FAQ
  • Related Array functions
  • Introspection
  • Accumulation
  • Sorting Sets
  • Shape
  • Creation
  • Combinatorics
  • Binning
  • Indexing
  • Grouping
  • Source you can read
  • About RunMat