Effacer les filtres
Effacer les filtres

How to call the output from gui button?

1 vue (au cours des 30 derniers jours)
Tara
Tara le 30 Avr 2013
Hello, here is my code
function load_data_Callback(~, ~, handles)
% hObject handle to load_data (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile('*.mat','Load Image');
if filename == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(pathname, filename);
storedata1 = load(fullFileName);
combineFIX=storedata1.combineFIX;
set(handles.edit20,'String',[pathname filename]);
set(handles.text13,'String','it works!');
and also here
function pushbutton22_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton22 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile('*.mat','Load Image');
if filename == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(pathname, filename);
storedata2 = load(fullFileName);
labels=storedata2.labels;
combineFIX=handles.combineFIX; %i try to call combineFIX from the button above,but it can't works
result_function; % a function that has labels and combineFIX as its input
set(handles.edit23,'String',[pathname filename]);
set(handles.text16,'String','numInst'); %numInst is the output of result_function
so, i want to call the combineFIX in the second button then do result_function and result numInst as its output. What should i do? thanks in advance.
  3 commentaires
Jan
Jan le 30 Avr 2013
Modifié(e) : Jan le 30 Avr 2013
What does "call the combineFIX" mean? What is "combineFIX" and what does "can't work" exactly mean?
I do not understand this also:
result_function; % a function that has labels and combineFIX as its input
No, result_function does not have any inputs.
Tara
Tara le 30 Avr 2013
combineFIX is a variable from .mat file in the load_data, and labels is a variable from .mat file in the pushbutton22. sorry, i mean result_function isn't a function, but it is M file, result_function.m that has variable combineFIX and labels. to display numInst from that result_function, i need combineFIX and also labels. so, how can i display the numInst from the pushbutton22?

Connectez-vous pour commenter.

Réponses (1)

Jan
Jan le 30 Avr 2013
If result_function is an M-file, but not a function, it must be a script. Inside the script you cann access all variables of the caller. In your case, labels and combineFIX can be used directly. So what is the problem?
Perhaps you should convert result_function to a function (then the name would be less confusing). Add this line on top:
function numInst = result_function(labels, combineFIX)
...
Then you have defined inputs and outputs.
  1 commentaire
Tara
Tara le 1 Mai 2013
my code doesn't work. it says
??? Reference to non-existent field 'combineFIX'.
Error in ==> guifix>pushbutton22_Callback at 836
combineFIX=handles.combineFIX;

Connectez-vous pour commenter.

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!

Translated by