How to call the output from gui button?
2 ビュー (過去 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 件のコメント
回答 (1 件)
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.
参考
カテゴリ
Help Center および File Exchange で Image Data Workflows についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!