File Exchange Pick of the Week

Accessing data from one widget to another in GUIDE 4

Posted by Doug Hull,

Last time, I showed how to add the newly documented UITABLE to a GUI. [click here] There were a few questions [click here] about how to access the data in the UITABLE from the callback of another widget. The answer to this question is applicable to all widgets, not just UITABLES. Basically, you are using the handles structure to access the handle of another control, then using the GET command to query it for its data.

Video Content

iconFiles.jpgiconPod.jpg

4 CommentsOldest to Newest

Dear Doug Hull

I was very impressed by your matlab videos.
You are doing an excellent job!

Cheers,
Eugene Sheynin

Can we access data from a widget in one GUI from another m-script (with its own GUI)?
I have a set of m-scripts to maintain. There is a main script that puts up a figure (window) with widgets including buttons to invoke other processes. The other processes are implemented by either ordinary Matlab functions intended to be called with a fixed number of arguments listed in the first line or m-files that use nargin and varargin to determine how many arguments exist. For the functions with fixed number of arguments, I can pass the GUI figure handles from the main script and use get and set to access and change them in the function. Is this a reasonable thing to do?
For the latter case–namely, in the functions that can have variable inputs–is there a way to access and change the data of the main function’s GUI?

Loretta,

Can you access the data from one widget from another script? If you have the handle to the widget, you can use GET to find them. To get the handle, you would want to capture it and pass it to your other function, use FINDOBJ to find it, or in some other means make that handle avaiable. You may need to set the handleVisibility property of your GUI so that things work out.

I do not understand your final question.

Thanks,
Doug

Hi Doug.
Let’s say I calculate some data within one of the widgets (assume a push button) and then want to use it somewhere else. How would you advise to convey the data?

These postings are the author's and don't necessarily represent the opinions of MathWorks.