Hi everyone,
I have a GUI set up and among other things, there is a 'start' pushbutton and a 'stop' pushbutton. Upon pushing the start, data is plotted on an adjacent axes and calculations are performed on the data. The plot is drawn using drawnow so that it plots in real time. What I am trying to do is while the data is plotting and calculations are being run, if the stop button is pressed, the plotting should stop and calculations should halt. This should be accomplished if I can just break the for loop, but everything I've tried hasn't succeeded. Here is what my code looks like:
What happens when the start button is pushed:
function startopen_Callback(hObject, eventdata, handles)
checkmachinef(handles,2);
Which calls checkmachinef and the code in question is
if command == 2;
for iz = first_turn:195
plot(handles.openaxes, Position(iz),Torque(iz),Position(first_turn:iz),Torque(first_turn:iz));
if Torque(iz)<0;
area(handles.openaxes, Position(first_turn:iz), Torque(first_turn:iz), 'FaceColor', [1 0 0]);
elseif Torque(iz)>0;
area(handles.openaxes, Position(first_turn:iz), Torque(first_turn:iz), 'FaceColor', [0 1 0]);
end
set(get(handles.openaxes,'XLabel'),'String','Position ({\circ})')
set(get(handles.openaxes,'YLabel'),'String','Torque (N-m)')
axis(handles.openaxes,[Position(first_turn), Position(1), minvalue, maxvalue])
drawnow;
pause(0.1);
stop_state = get(handles.stopopen, 'Value');
if stop_state
break
end
end
end
As you can see, I try to get the value of the stop pushbotton and if true then it breaks the loop, however nothing happens when I run the program, start the plot, then click stop. Any ideas? Thank you in advance