MATLAB: Names of variables

functionspass calling variablesvariable name

Is it possible inside function to know the names of variables, which are used during call of this function? How to pass them inside it?

Best Answer

IF those input arguments had names in the calling workspace of this function (which is not guaranteed) it is possible to retrieve those names using the inputname function.
However, I would be hesitant to use this information other than perhaps to use in an error message or text that you display as some sort of status. If you're thinking to use it with assignin to modify variables in your caller's workspace, I STRONGLY recommend against that unless there is no other way to do what you need (and even then, post about what you're trying to do on Answers to see if others can think of a better solution.) Doing that is likely to make debugging very difficult later on, and is an example of common coupling or perhaps even a form of content coupling. Prefer data coupling instead if possible.