For my own understanding, I am trying to create a simple counter GUI with 2 pushbuttons namely 'Start counting' and 'Stop counting'
Start counting - Starts the counter
Stop counting - Stops the counter
I am having troubles to Stop the running counter using the Stop pushbutton. For some reason the handles.stop which gets set to 1 in the StopCounter_Callback does not reflect in the StartCounter_Callback.
Here is the piece of code.
Any help will be much appreciated. Thanks in advance.
function StartCounter_Callback(hObject, eventdata, handles)
counter = 0;
handles.start = 1;
if (handles.stop == 0)
counter = counter + 1;
myString = sprintf('Value is %d', counter);
set(handles.text1, 'String', myString);
% Reset the Start & Stop button
handles.stop = 0;
handles.start = 0;
% --- Executes on button press in StopCounter.
function StopCounter_Callback(hObject, eventdata, handles)