Skip to content

inputname

builtin · libnexusinterp/parse-tree/pt-eval-proprietary.cc

: namestr = inputname (n)
: namestr = inputname (n, ids_only)

Return, as a string, the name of the n-th argument passed to the function from which inputname is called.

n must be a positive integer scalar that indexes the argument list of the calling function.

By default (ids_only true) a name is produced only when the matching argument was supplied as a plain variable; if it was anything else – a literal such as 5.1, an expression such as y/2, or an indexing result such as c{1} or s.field – the empty string is returned instead.

Passing ids_only as false lifts that restriction and returns the source text of the argument even when it is not a simple variable name, letting a function observe exactly how it was invoked. This second argument is a Nexus extension beyond MATLAB.

inputname is meaningful only inside a function. At the command line or within a script it always returns the empty string.