Using guidata or setappdata seem to call OpeningFcn
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Gorm Dannesboe am 31 Mär. 2022
Kommentiert: Geoff Hayes am 1 Apr. 2022
I have made a GUI using GUIDE in Matlab R2016a that plots simulation data. It is mostly working fine, but recently I have added a second GUI for importing measurement data.
In the second GUI I browse to the data, select the data I want to plot, and send to the main GUI using setappdata.
In the main GUI I call the data using getappdata:
NonInvasive.Data = getappdata(LoopGainPlotterGUIv1_5,'NonInvasiveData');
The data is transfered just fine, and I can plot it, but it seems like all my handle variables in the main GUI (LoopGainPlotterGUIv1_5) are being reset as in the opening function of the main GUI. This is a big problem for me since it is then no longer possible for the GUI to know what has been plotted etc.
I have also noticed that if I write the following in the command window, then it also resets my handles in the main GUI. At least that is what it looks like since the written out variables are all wrong and the GUI no longer works as intended.
B = guidata(LoopGainPlotterGUIv1_5)
If I just read out handles by adding
to a button callback then all is good, as long as I haven't passed data from the second GUI.
I have looked far and wide for an explanation, but cannot find anywhere mentioning such behaviour. Is it really so, that the opening function is being called using setappdata or guidata outside the GUI figure?
Geoff Hayes am 31 Mär. 2022
@Gorm Dannesboe - I suspect that everytime you call the GUI by name, LoopGainPlotterGUIv1_5, you are creating a new instance of the GUI. If you want to communicate between two open GUIs (GUIs created in GUIDE) then you can do something similar to what is discussed at Pass Data between GUIs.
Geoff Hayes am 1 Apr. 2022
@Gorm Dannesboe - if LoopGainPlotterGUIv1_5 is the name of the GUI, then calling this will instantiate a new instance of the GUI and so call the OpeningFunc every time.
Weitere Antworten (0)
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!