inputParser — Parse MATLAB-style optional name-value arguments.
inputParser creates a handle object for parsing common MATLAB name-value argument patterns. RunMat supports the minimal workflow used by imported helper functions: create a parser, register parameters with defaults, parse varargin{:}, and read values from p.Results.
Syntax
p = inputParser()Returns
p- Type
Any- Description
- inputParser handle object.
Behavior
p = inputParser returns a handle object with an initially empty Results struct.
addParameter(p, name, default) registers a case-sensitive name and default value, mutating p in place.
parse(p, name, value, ...) starts from the registered defaults and applies exact name matches.
p.Results.<name> reads the parsed value for a registered parameter.
Duplicate parameter names, odd name-value argument counts, non-text names, and unknown parsed names raise stable RunMat errors.
This compatibility slice does not yet implement addRequired, addOptional, validators, CaseSensitive, PartialMatching, KeepUnmatched, or StructExpand.
Execution and residency
inputParser stores host-side metadata and parsed values.
Supported parser contract
inputParser supports case-sensitive named parameters with defaults. addParameter registers a parameter and rejects duplicates. parse accepts complete name-value pairs, rejects unknown names, uses the last supplied value for duplicates, and publishes Results only after validation. The current implementation does not support validators, positional parameters, or parser configuration options.
Examples
Parse an optional scale parameter
result = f('scale', 4);
function y = f(varargin)
p = inputParser;
addParameter(p, 'scale', 2);
parse(p, varargin{:});
y = p.Results.scale;
endExpected output:
ans =
4Use a registered default when the name is omitted
p = inputParser;
addParameter(p, 'scale', 2);
parse(p);
p.Results.scaleExpected output:
ans =
2Parse a named parameter
p = inputParser(); addParameter(p, 'Count', 2); parse(p, 'Count', 5); result = p.Results.Count;Using inputParser with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how inputParser changes the result.
Run a small inputParser example, explain the result, then change one input and compare the output.
FAQ
Are parameter names case-sensitive?⌄
Yes. This initial RunMat implementation uses exact case-sensitive name matching.
Does RunMat support validators or positional arguments?⌄
Not yet. The current support is intentionally limited to optional name-value parameters registered with addParameter.
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 · 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
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.