필터 지우기
필터 지우기

How to call the output from gui button?

조회 수: 2 (최근 30일)
Tara
Tara 2013년 4월 30일
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
Jan
Jan 2013년 4월 30일
편집: Jan 2013년 4월 30일
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 2013년 4월 30일
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?

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2013년 4월 30일
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
Tara
Tara 2013년 5월 1일
my code doesn't work. it says
??? Reference to non-existent field 'combineFIX'.
Error in ==> guifix>pushbutton22_Callback at 836
combineFIX=handles.combineFIX;

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by