Here is my test code for toggle button, the 'i' value in for loop gets cleared every time when it returns from toggle state and starts executing from first, How to continue from same point without using counters or manually storing the values
if true function togglebutton1_Callback(hObject, eventdata, handles) button_state = get(hObject,'Value'); if button_state == 1 for i=1:10 disp('hi'); pause(1); else while(1) pause(0.1) end end end
Best Answer