フィルターのクリア

Variable usage in Callbacks

1 回表示 (過去 30 日間)
Subhiksha
Subhiksha 2013 年 9 月 26 日
編集済み: Jan 2013 年 9 月 26 日
Hello, I have two callback functions named as file_Callback and loaddataset_Callback
function file_Callback(hObject, eventdata, handles) % hObject handle to file (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) guidata(hObject,handles) ; %end
% --------------------------------------------------------------------
function dataset=loaddataset_Callback(hObject, eventdata, handles) % hObject handle to loaddataset (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) %%Load the file from the user interface
%Initialize variables
proceed = 1;
k=1;
disp(a)
while ( proceed == 1 )
%Get the path and name of matfile loaded
[filename,pathname,filterindex]=uigetfile('*.mat');
filepath = [pathname,filename];
%Store the path and name in an array
handles.dataset(k)=cellstr(filepath);
% handles.listbox = '0';
%%confirm if the dataset loaded is right
msg = ['You have loaded ',filename,'. Do you want to load an other dataset of the same subject??'];
load=questdlg(msg, 'Dataset Loaded');
load1 = strcmp (load,'Yes');
%To load another dataset of same subject
if( load1 == 1 )
proceed = 1;
k=k+1;
else
proceed = 0;
end
end
% disp((handles.dataset))
guidata(hObject, handles);
% -------------------------------------------------------------------- %end
I need to declare a variable in file_Callback and use the same variable in loaddataset_Callback.
How to do this??
Thanks in advance
  1 件のコメント
Jan
Jan 2013 年 9 月 26 日
Please format your code properly when you want to encourage others to read it.

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

回答 (1 件)

Jan
Jan 2013 年 9 月 26 日
編集済み: Jan 2013 年 9 月 26 日
This topic has been discussed repeatedly here. So please search for "share data GUI" in this forum.
A very useful tool is included in the source code you've posted already: guidata. New variables can be appended to the handles struct, while guidata stores and obtains the current struct to / from the GUI.

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by