Effacer les filtres
Effacer les filtres

Pass variables between Guis created using Guide

1 vue (au cours des 30 derniers jours)
Zine
Zine le 2 Avr 2014
Réponse apportée : Zine le 4 Avr 2014
I have created a GUI using GUIDE named MainGui,
this gui will process data and give results to other gui named outputGui created also with guide,
the data processed comes from an inputGuis that process some inputs and generate the data to be sent to MainGui , processing and sending data to MainGui happens when I push a button in an inputGui then inputGui will be closed
my question is: is there any way to pass data from one gui to another knowing that the guis are in separate figures and have separate .m files and they are not programmatic guis
thanks in advance
  2 commentaires
Zine
Zine le 2 Avr 2014
I tried to use setappdata and getappdata but I did not succeed to do it, so please if you have some way near to this because I am a beginner with MATLAB
Dishant Arora
Dishant Arora le 2 Avr 2014
Attach your m files.

Connectez-vous pour commenter.

Réponse acceptée

David Sanchez
David Sanchez le 2 Avr 2014
I good way to do it is declaring global variables. In case you need to "transfer" a whole lot of variables, it is more practical to declare a global struct ,how? Right after the declaration of any function in any of your GUIs, define:
global global_struct
( for example: function your_fun(inputs) global global_struct ... ... )
where global_struct can be renamed as you please. To save a variable:
global_struct.var1 = whatever; % for example: global_struct.var1 = srt2double(get(handles.box1,'String')); )
global_struct.var2 = anything_you_want;
The variables will be accessible for any function/GUI and can be modify too.
  1 commentaire
Zine
Zine le 2 Avr 2014
thanks David, I have one question about the use of global variables, if the input GUI set globalstruct.var1=value1; and close it self by the command close, do the MainGui still can see the variable globalstruct.var1, or I should not close the input Gui but just hide it and how to hide it.
thanks in advance

Connectez-vous pour commenter.

Plus de réponses (2)

Joseph Cheng
Joseph Cheng le 2 Avr 2014
If you want to get way from the use of global variables you try guidata(). A quick search of the forums came up with this link https://www.mathworks.com/matlabcentral/newsreader/view_thread/254309. which discusses how they were able to pass data between the "main" gui and a "sub" gui.

Zine
Zine le 4 Avr 2014
Thanks to whom answered and tried to answer me; I found a solution for that by using this answer just adjust it according to the problem, (it is detailed procedure that was working for me)

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by