How can I share data between two GUIs in MATLAB 8.0 (R2012b)?

4 views (last 30 days)
I have two GUIs: one is the parent GUI which calls the second (child) GUI. I want to share information between parent and the child GUI.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 15 Nov 2012
Sharing data between two GUIs is illustrated by the following example in the MATLAB documentation:
Execute the following
web([docroot '/matlab/code-to-run-the-gui.html'])
at the MATLAB command prompt, and then click on the link:
Data Management in a GUIDE GUI
Data Management in a Programmatic GUI
depending upon whether you used Graphical User Interface Development Environment (GUIDE) to create your GUIs or not.
One of the ways to share data between GUIs is explained below:
To share data between the parent GUI and the child GUI, you can make use of the SETAPPDATA and the GETAPPDATA functions in MATLAB. In the example code attached with this solution, "GUI1.fig" is the parent GUI which invokes "GUI2.fig" which is the child GUI. The child GUI shares the information entered in its EDIT box using the SETAPPDATA function as shown below:
The parent GUI retrieves this information and displays it in its own edit box using the code shown below:
The child GUI is invoked from within the pushbutton callback of the parent GUI as shown below:
h = GUI2;
You may also refer to Video: GUIDE Basics Tutorial by Doug Hull posted on MATLAB Central
Regarding the MATLAB Central reference, please note that MATLAB Central is a user community and that MathWorks does not support the technical content posted on it, neither does it guarantee the accuracy of the content. Any questions about the content posted on MATLAB Central should be raised to the author directly.
  1 Comment
mohanish on 15 Oct 2018
how do you pass data which is not 'string' but a whole matrix of coefficients?

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!