MATLAB Answers

get the name of variable

7 views (last 30 days)
Hassan on 12 Jun 2011
I have two variables, myData and x. at some point I want to use the name of vriable assigned to x, i.e. myData. I wonder how i can get it? I apperciate your help.
myData=[1 2 3];
%now I want to get the name of vavriable assigned to x
myText=x >>>>myText='myData'

Answers (1)

Paulo Silva
Paulo Silva on 12 Jun 2011
No variable was assigned to x, the code x=myData; just copies the contents of the variable myData to the variable x, you are the one that knows the name of the variable on your code so save it to use later
myData=[1 2 3];
myText=x >>>>myText=xGotValOf;
Jan on 12 Jun 2011
@Hassan: It is worth to mention, that Paulo Silva is not called Paula Silvo, Pilva Saulo, Pausi Lolva or Pava Silulo. He is Paulo. ;-)

Sign in to comment.


Community Treasure Hunt

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

Start Hunting!