Grabbing variable names when passing into function

I would like to store a variable name, in addition to its content, when I pass it into a function. For example:
[VarData, VarName]= sampleFunct (inputVar)
I am writing the instantiation of my object (in OOP) and noticed that the name of one the variables that I am passing in is also useful, in addition to the data it contains.
I know I could just add a second parameter that allows me to input a string that I could assign to the name, but to streamline things and to reduce errors, I'd like to find a way to grab the variable's name.
I prefer NOT to alter the content of my inputVar, I just want to see what it had previously been named.
There may be a very simple way to do this. Thanks!

 採用された回答

Matt Fig
Matt Fig 2011 年 6 月 7 日

0 投票

See the help for INPUTNAME.

1 件のコメント

Paulo Silva
Paulo Silva 2011 年 6 月 7 日
That function is new to me and might be useful soon, thanks Matt

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeVariables についてさらに検索

タグ

質問済み:

2011 年 6 月 7 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by