How do I return callback value from GUI to workspace
이전 댓글 표시
As part of a bigger app to analyze people's gait, for this part of the code, I'm trying to detect whether one of the two buttons has been pressed so that it can be followed by an if statement. I've been trying to use a callback function to return value from child function to workspace, not just display in the command window, so that it can keep codes flow but it didn't work. It seems very simple but I can't solve it.
close all
clear
clc
prompt = 'Do you want to optimize Minibatch before processing session data?';
%%
newfigure = figure;
newfigure.Position = [500 350 600 300];
handles.button = 0
button_yes = uicontrol(newfigure,'Style','pushbutton',...
'String','Yes',...
'FontSize',12,...
'Position',[50 50 200 100],...
'Callback',@button_yes_callback);
button_no = uicontrol(newfigure,'Style','pushbutton',...
'String','No',...
'FontSize',12,...
'Position',[350 50 200 100],...
'Callback',@button_no_callback);
headline = uicontrol(newfigure,'Style','text',...
'String',prompt,...
'Position',[0 200 600 30],...
'FontSize',12,...
'HorizontalAlignment','Center',...
'HandleVisibility','off');
guidata(newfigure,handles)
%%
function button_yes_callback(hObject,eventdata,handles)
handles.button = 1
disp('Fist Button was pressed.');
guidata(hObject,handles);
end
function hObject = button_no_callback(hObject,eventdata,handels)
handles.button = 0
disp('Second Button was pressed.');
guidata(hObject,handles);
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!