Skip to Main Content Skip to Search
Product Documentation

inputname - Variable name of function input

Syntax

inputname(argnum)

Description

This command can be used only inside the body of a function.

inputname(argnum) returns the workspace variable name corresponding to the argument number argnum. If the input argument has no name (for example, if it is an expression instead of a variable), the inputname command returns the empty string ('').

Examples

Suppose the function myfun.m is defined as

function c = myfun(a,b)
fprintf('First calling variable is "%s"\n.', inputname(1))

Then

x = 5;  y = 3;  myfun(x,y)

produces

First calling variable is "x".

But

myfun(pi+1, pi-1)

produces

First calling variable is "".

See Also

nargchk | nargin | nargout

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS