Variable usage in Callbacks
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Réponses (1)
Jan
le 26 Sep 2013
Modifié(e) : Jan
le 26 Sep 2013
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.
0 commentaires
Voir également
Catégories
En savoir plus sur Workspace Variables and MAT-Files dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!