I'm trying to make a GUI that pops up as soon as the main function starts and it contains a checkbox that can be used to stop the program when it is in a loop:
function mainFcnh.fig = figure('Position', [100 100 100 100]);h.cancelBox = uicontrol('Style', 'checkbox',... 'String', 'Cancel?',... 'Position', [10 10 10 10]);set(h.cancelBox, 'callback', {@cancelBox, h});drawnow;i = 1;while i == 1 value = get(h.cancelBox, 'Value'); if value == 1 i = 0; else i = 1; endendfunction cancelBox(hObject, eventdata, handles)set(hObject, 'Value', 1);guidata(hObject, handles);
When I use disp(value); to see the value I am getting for the current value of the checkbox. It always says that the checkbox has a value of 0.
Best Answer