Using guidata in a GUIDE GUI
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I created a gui, which has many editable texts as input parameters, many buttons and axes. Some button presses call functions which run simulations based on the parameters given as input. When these functions calculate the results, the graphs are plotted in the axes.
I want to have two buttons for each axes, one for "Save graph as jpg" and another for "Save data as CSV". For this I need the functions which are called inside the callback of buttons to save the calculated data somewhere, because these data must be accessible by the "Save data as CSV" button's callback. I solved this by putting the data into the guidata like the following:
handles.MyData = DataToPlot;
guidata(MyGUI,handles);
In this code a MyData handle is created for the data in DataToPlot, and the handles of MyGUI are updated by guidata(MyGUI,handles). This works, I save the data to a txt file with dlmwrite() later. However, I encounter two problems: 1. The program becomes extremely slow. A simulation run which was about 30 seconds without using 'guidata' now is in the order of magnitude of about 5-10 minutes. 2. Whenever guidata is used, I think the opening function of the gui runs as well. (I am not sure about this, but some controls which are initially visible, but made invisible by buttons on the GUI become visible again after the usage of guidata, and the opening screen of the GUI is seen again.)
Does someone know how to get around this issue? What kind of function can be used instead of the code given above to pass data between functions of a GUI?
Thank you for your answers in advance. László
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 17 Jun. 2012
MyGUI is the name of your GUI itself, right? If so then
guidata(MyGUI, handles)
runs MyGUI.m and takes its output and passes that to guidata()
Do not use the name of your GUI as a parameter to guidata: instead use the handle of your GUI figure. Which, if you only have one figure, will be accessible as gcf()
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!