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.2, Nov 26, 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
    • addlistener
    • addParameter
    • addprop
    • assignin
    • builtin
    • cancel
    • class
    • clear
    • clearAllMemoizedCaches
    • clearCache
    • clearvars
    • dbclear
    • dbstack
    • dbstatus
    • dbtype
    • eval
    • evalc
    • evalin
    • feval
    • findprop
    • func2str
    • functions
    • get.p
    • getcallinfo
    • getmethod
    • inputname
    • inputParser
    • isa
    • ischar
    • isdeployed
    • iskeyword
    • ismethod
    • isobject
    • isstring
    • isUnderlyingType
    • isvalid
    • keyboard
    • loadobj
    • localfunctions
    • matlab.metadata.DynamicProperty.delete
    • memoize
    • metaclass
    • mfilename
    • mislocked
    • mlock
    • munlock
    • namelengthmax
    • narginchk
    • nargoutchk
    • new_object
    • notify
    • numArgumentsFromSubscript
    • onCleanup
    • parse
    • saveobj
    • set.p
    • stats
    • str2func
    • subsasgn
    • subsref
    • superclasses
    • underlyingType
    • verLessThan
    • version
    • which
    • who
    • whos

nargoutchk — Validate requested function outputs or return a legacy output-count message.

nargoutchk(minArgs,maxArgs) throws when the current function's requested output count is outside the bounds. The discouraged three- and four-input forms validate an explicit count and return a message instead of throwing for a count violation.

Syntax

nargoutchk(minArgs, maxArgs)
msgText = nargoutchk(minArgs, maxArgs, numArgs)
msgStruct = nargoutchk(minArgs, maxArgs, numArgs, 'struct')

Inputs

minArgs
Type
NumericScalar
Required
Yes
Description
Minimum allowed argument count.
maxArgs
Type
NumericScalar
Required
Yes
Description
Maximum allowed argument count.
numArgs
Type
NumericScalar
Required
Yes
Description
Legacy explicit output count to validate.
outputType
Type
StringScalar
Required
Yes
Default
struct
Description
Literal struct output selector.
NameTypeRequiredDefaultDescription
minArgsNumericScalarYes—Minimum allowed argument count.
maxArgsNumericScalarYes—Maximum allowed argument count.
numArgsNumericScalarYes—Legacy explicit output count to validate.
outputTypeStringScalarYesstructLiteral struct output selector.

Returns

msg
Type
Any
Description
Legacy message text or structure.
NameTypeDescription
msgAnyLegacy message text or structure.

Errors

RunMat:NotEnoughOutputs
When
The current function was called with fewer requested outputs than the lower bound.
Message
nargoutchk: not enough output arguments
RunMat:TooManyOutputs
When
The current function exceeds maxArgs or the caller requests more results than the selected form returns.
Message
nargoutchk: too many output arguments
RunMat:NargoutchkArgumentInvalid
When
A bound argument is not a nonnegative integer scalar or valid Inf upper bound.
Message
nargoutchk: bounds must be nonnegative integer scalars
IdentifierWhenMessage
RunMat:NotEnoughOutputsThe current function was called with fewer requested outputs than the lower bound.nargoutchk: not enough output arguments
RunMat:TooManyOutputsThe current function exceeds maxArgs or the caller requests more results than the selected form returns.nargoutchk: too many output arguments
RunMat:NargoutchkArgumentInvalidA bound argument is not a nonnegative integer scalar or valid Inf upper bound.nargoutchk: bounds must be nonnegative integer scalars
RunMat:NargoutchkBoundsInvalidThe minimum bound is greater than the maximum bound.nargoutchk: minArgs must be less than or equal to maxArgs
RunMat:NargoutchkContextUnavailableThe runtime dispatcher is invoked without VM function-call context.nargoutchk: function call context is unavailable

Forms and results

The two-input form uses the selected function invocation's requested output count and produces no output; requesting a result reports RunMat:TooManyOutputs. A script or context-free embedding has no function output count and reports RunMat:NargoutchkContextUnavailable after its bounds are admitted.

msg = nargoutchk(minArgs,maxArgs,numArgs) returns character message text on a violation and an empty 0-by-0 character array otherwise. With a fourth 'struct' selector it returns a structure with message and identifier fields on a violation and an empty structure otherwise. These legacy forms return at most one result; a discarded call produces no result.

minArgs, maxArgs, and legacy numArgs accept scalar single, double, or any of the eight integer classes. Positive single or double infinity is allowed only for maxArgs. Exact integer storage is compared without floating conversion; out-of-range counts reject rather than round or saturate.

Interactive resident controls are not documented and reject before provider access. These forms are host-only and perform no provider operation or callback.

Examples

Require one requested function output

y = arity_output_probe(7);

Inspect an explicit output-count violation

msg = nargoutchk(1,1,0); detail = nargoutchk(1,1,0,'struct');

Using nargoutchk with coding agents

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

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

Related Introspection functions

addlistener · addParameter · addprop · assignin · builtin · cancel · class · clear · clearAllMemoizedCaches · clearCache · clearvars · dbclear · dbstack · dbstatus · dbtype · eval · evalc · evalin · feval · findprop · func2str · functions · get.p · getcallinfo · getmethod · inputname · inputParser · isa · ischar · isdeployed · iskeyword · ismethod · isobject · isstring · isUnderlyingType · isvalid · keyboard · loadobj · localfunctions · matlab.metadata.DynamicProperty.delete · memoize · metaclass · mfilename · mislocked · mlock · munlock · namelengthmax · narginchk · new_object · notify · numArgumentsFromSubscript · onCleanup · parse · saveobj · set.p · stats · str2func · subsasgn · subsref · superclasses · underlyingType · verLessThan · version · which · who · whos

Source you can read

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

  • View the source for nargoutchk 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
  • Forms and results
  • Examples
  • Require one requested function output
  • Inspect an explicit output-count violation
  • Using nargoutchk with coding agents
  • Related Introspection functions
  • Source you can read
  • About RunMat