get the name of variable

조회 수: 2 (최근 30일)
Hassan
Hassan 2011년 6월 12일
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];
x=myData;
%now I want to get the name of vavriable assigned to x
myText=x >>>>myText='myData'

답변 (1개)

Paulo Silva
Paulo Silva 2011년 6월 12일
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];
x=myData;
xGotValOf='myData';
myText=x >>>>myText=xGotValOf;
  댓글 수: 2
Hassan
Hassan 2011년 6월 12일
thanks Paula for the comment. I thought it is possible but seems not.
Jan
Jan 2011년 6월 12일
@Hassan: It is worth to mention, that Paulo Silva is not called Paula Silvo, Pilva Saulo, Pausi Lolva or Pava Silulo. He is Paulo. ;-)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by