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

narginchk — Validate the number of inputs supplied to the current function.

narginchk(minArgs,maxArgs) throws when the current function received fewer than minArgs or more than maxArgs inputs.

Syntax

narginchk(minArgs, maxArgs)

Inputs

NameTypeRequiredDefaultDescription
minArgsNumericScalarYes—Minimum allowed argument count.
maxArgsNumericScalarYes—Maximum allowed argument count.

Errors

IdentifierWhenMessage
RunMat:NotEnoughInputsThe current function was called with fewer inputs than the lower bound.narginchk: not enough input arguments
RunMat:TooManyInputsThe current function was called with more inputs than the upper bound.narginchk: too many input arguments
RunMat:NarginchkArgumentInvalidA bound argument is not a nonnegative integer scalar or valid Inf upper bound.narginchk: bounds must be nonnegative integer scalars
RunMat:NarginchkBoundsInvalidThe minimum bound is greater than the maximum bound.narginchk: minArgs must be less than or equal to maxArgs
RunMat:NarginchkContextUnavailableThe runtime dispatcher is invoked without VM function-call context.narginchk: function call context is unavailable

How narginchk works

  • minArgs accepts nonnegative scalar single, double, or any of the eight integer classes.
  • maxArgs accepts the same classes and also positive double infinity for an unbounded maximum.
  • All integer classes are read from authoritative scalar storage without floating conversion.
  • The minimum cannot exceed the maximum, and bounds outside the host argument-count range are rejected rather than rounded or saturated.
  • The check uses the current VM function-call context and has no output value.

Example

Require one or two inputs

function y = f(x, varargin)
    narginchk(1, 2);
    y = x;
end

Expected output:

Calls with one or two inputs continue; other calls throw.

Using narginchk with coding agents

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

Run a small narginchk 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 · nargoutchk · 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 narginchk is executed, line by line, in Rust.

  • View the source for narginchk 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
  • Errors
  • How narginchk works
  • Example
  • Require one or two inputs
  • Using narginchk with coding agents
  • Related Introspection functions
  • Open-source implementation
  • About RunMat