フィルターのクリア

Using guidata in a GUIDE GUI

1 回表示 (過去 30 日間)
László Arany
László Arany 2012 年 6 月 17 日
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ó

採用された回答

Walter Roberson
Walter Roberson 2012 年 6 月 17 日
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()
  1 件のコメント
László Arany
László Arany 2012 年 6 月 17 日
Thank you very much! I quite misunderstood the operation of guidata...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by