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
    • addprop
    • assignin
    • class
    • clear
    • clearAllMemoizedCaches
    • clearCache
    • clearvars
    • dbclear
    • dbstack
    • dbstatus
    • dbtype
    • evalc
    • feval
    • findprop
    • getcallinfo
    • inputParser
    • isa
    • ischar
    • isdeployed
    • iskeyword
    • ismethod
    • isobject
    • isstring
    • isUnderlyingType
    • keyboard
    • matlab.metadata.DynamicProperty.delete
    • memoize
    • metaclass
    • mislocked
    • mlock
    • munlock
    • namelengthmax
    • narginchk
    • nargoutchk
    • notify
    • onCleanup
    • stats
    • str2func
    • superclasses
    • underlyingType
    • verLessThan
    • version
    • which
    • who
    • whos

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

nargoutchk(minArgs,maxArgs) throws when the current function's requested output count is outside the bounds. The discouraged legacy forms return message text or a message structure for an explicit numArgs count.

Syntax

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

Inputs

NameTypeRequiredDefaultDescription
minArgsNumericScalarYes—Minimum allowed argument count.
maxArgsNumericScalarYes—Maximum allowed argument count.
numArgsNumericScalarYes—Legacy explicit output count to validate.
outputTypeStringScalarYesstructLiteral struct output selector.

Returns

NameTypeDescription
msgAnyLegacy message text or structure.

Errors

IdentifierWhenMessage
RunMat:NotEnoughOutputsThe current function was called with fewer requested outputs than the lower bound.nargoutchk: not enough output arguments
RunMat:TooManyOutputsThe current function was called with more requested outputs than the upper bound.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

How nargoutchk works

  • minArgs, maxArgs, and legacy numArgs accept scalar single, double, or any of the eight integer classes; positive double infinity is allowed only as maxArgs.
  • All integer classes are read from authoritative scalar storage without floating conversion.
  • The two-argument form uses the current VM output-call context and throws on a violation.
  • msg = nargoutchk(minArgs,maxArgs,numArgs) returns character message text on a violation and an empty 0×0 character array otherwise.
  • msg = nargoutchk(minArgs,maxArgs,numArgs,'struct') returns a structure with message and identifier fields on a violation and an empty structure otherwise.
  • Bounds outside the host argument-count range are rejected rather than rounded or saturated.

Example

Require exactly one requested output

function y = f(x)
    nargoutchk(1, 1);
    y = x;
end

Expected output:

Calls requesting exactly one output continue; other calls throw.

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

addprop · assignin · class · clear · clearAllMemoizedCaches · clearCache · clearvars · dbclear · dbstack · dbstatus · dbtype · evalc · feval · findprop · getcallinfo · inputParser · isa · ischar · isdeployed · iskeyword · ismethod · isobject · isstring · isUnderlyingType · keyboard · matlab.metadata.DynamicProperty.delete · memoize · metaclass · mislocked · mlock · munlock · namelengthmax · narginchk · notify · onCleanup · stats · str2func · superclasses · underlyingType · verLessThan · version · which · who · whos

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. 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 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 nargoutchk works
  • Example
  • Require exactly one requested output
  • Using nargoutchk with coding agents
  • Related Introspection functions
  • Open-source implementation
  • About RunMat