필터 지우기
필터 지우기

Matlab GUI - Enter variable name in the Edit Text box

조회 수: 2 (최근 30일)
F.L.
F.L. 2016년 10월 20일
댓글: F.L. 2016년 10월 20일
Hi, I'm a newbie of the matlab environment, especially for GUI. I'm writing this little script and I need that the user can enter the NAME of a variable (saved in the workspace and already "evalin" in GUI) in an editable text box. So, that's the issue: how I can recall the VALUE of that variable (which is a MATRIX) and use it in the script? Thank you!
  댓글 수: 2
Adam
Adam 2016년 10월 20일
편집: Adam 2016년 10월 20일
It's hard to think of a situation in which you would really want to do this. Variable names are just something for the code or the coder to use to create the program. A GUI is for a user who should be abstracted away from anything involving variable names. Usually you would just put things on the GUI that make sense to a user and then under the GUI you interpret those as necessary for the program. In a normal usage a user of a GUI shouldn't know what variables are in the base workspace because the GUI uses its own hidden workspace.
You can use horrible constructs involving eval to do this, but they are so unpleasant I have purposely never learned the syntax to do so, but no doubt someone will provide an answer along those lines soon enough.
F.L.
F.L. 2016년 10월 20일
편집: F.L. 2016년 10월 20일
Thanks for your comment Adam, but that's what I need. I run a similar procedure using just a script in the workspace and there you can easily use the input command to ask the user. But I have troubles with GUI.

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

답변 (1개)

Pritesh Shah
Pritesh Shah 2016년 10월 20일
You can save in .mat file and load data in script.
check doc save and doc load in matlab command
  댓글 수: 1
F.L.
F.L. 2016년 10월 20일
Thank you, but how I can save the matrix? I mean, If I try to save, uisave just save the name of the variable (entered in the text box) and not the variable itself.

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

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by