필터 지우기
필터 지우기

Getting external variables from GUI

조회 수: 2 (최근 30일)
Francisco Gómez
Francisco Gómez 2011년 5월 18일
Hi!
I want to know if there's some way for a GUI made with GUIDE to access external vars. (Or how to give the GUI these vars)
Thanks you a lot!

채택된 답변

Matt Fig
Matt Fig 2011년 5월 18일
Yes, there are many ways to do this. One way is to use EVALIN. Let's say you have a variable named g in the base workspace. Then in the callback to a pushbutton, put this:
g = evalin('base','g')
Another method is to store the variables you want in the GUIDATA structure of the GUI. See the help for GUIDATA to understand its use. Note that GUIDE GUIs are invisible to GCF, so you will have to use FINDALL to access the GUI handle from the base workspace. Perhaps easier would be to store the data in the userdata property of the root object.
set(0,'userdata',mydata); % At the command line or wherever
Then from in the GUI:
mydata = get(0,'userdata') % In a callback.
  댓글 수: 1
Francisco Gómez
Francisco Gómez 2011년 5월 18일
Thanks you both for the help ;)

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

추가 답변 (1개)

Andy
Andy 2011년 5월 18일
Another way is to save your data to a .mat file and load it in your GUI at runtime. Create a 'Load' button in your GUI, with callback like:
data = load(yourdatafile)
Then you also have the ability to save multiple different sessions and load different sessions into your GUI by asking the user for the data file to load.
  댓글 수: 1
Francisco Gómez
Francisco Gómez 2011년 5월 18일
Thanks you both for the help ;)

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

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by