フィルターのクリア

How to retrieve data from one gui to another?

2 ビュー (過去 30 日間)
Nur Fauzira Saidin
Nur Fauzira Saidin 2015 年 5 月 6 日
コメント済み: Geoff Hayes 2015 年 5 月 7 日
I have two GUIs. The first one I want to plot a sine signal at axes 3 (as in pic 1). My problem is, how can I retrieve back the graph into the axes 1 of the second GUI (as in pic 2) after I clicked the 'load data' pushbutton? I really need help here.
GUI_1 (pic 1)
GUI_2 (pic 2)

採用された回答

Geoff Hayes
Geoff Hayes 2015 年 5 月 7 日
Nur - see http://www.mathworks.com/matlabcentral/answers/146215-pass-data-between-gui-s as one example on how to pass data between two GUIs.
  2 件のコメント
Nur Fauzira Saidin
Nur Fauzira Saidin 2015 年 5 月 7 日
I found many example actually but I still couldn't understand it. Can you help? I named my first GUI as 'sine_signal' (tag: gui_sine) and the other GUI as 'filtering' (tag: gui_filtering).
Geoff Hayes
Geoff Hayes 2015 年 5 月 7 日
Nur - there are probably several different ways to do this, so here is one. Let's assume that you have two GUIs named gui_sine and gui_filtering and that they are distinct GUIs (i.e. you are not running two instances of the same one). In the Property Inspector for Gui1, set the HandleVisibility property to on , and the Tag property to gui_sine. This will allow us to search for the GUI given its (unique) tag. Do the same for the other GUI (except name the tag gui_filtering). Save both.
Now suppose that in gui_filtering you want access to some of the data in the first GUI. What you require, is the handle to the latter. In a (say) push button callback of gui_filtering, you can add the following code
function pushbutton1_Callback(hObject, eventdata, handles)
% get the handle of gui_sine
h = findobj('Tag','gui_sine');
% if exists (not empty)
if ~isempty(h)
% get handles and other user-defined data associated to gui_sine
g1data = guidata(h);
% maybe you want to set the text in gui_filtering with that from gui_sine
set(handles.text1,'String',get(g1data.edit1,'String'));
end
The above example tests a way in which we can get data from the other GUI - use either guidata which gives us the handles to all widgets of the first AND any user-defined data that had been saved in that GUI to the handles object as (for example)
function pushbutton3_Callback(hObject, eventdata, handles)
% in some gui_sine callback, we create the following xData field in the handles
% structure
handles.xData = -2*pi:0.0001:2*pi;
% now we save the data
guidata(hObject,handles);
We then access this data as shown previously.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by