Create the following function in a file, getname.m , in your current working folder.

function getname(a,b) s = inputname(1); disp([ 'First calling variable is ''' s '''.' ]) end

Call the function at the command prompt using the variables x and y .

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

First calling variable is 'x'.

Call the function using values instead of variables. The inputname function returns an empty char array because its input does not have a name.

getname(5,3)