Toggle Button callback difficulty
    2 views (last 30 days)
  
       Show older comments
    
I want to controll the number of Needle increasing and decreasing through a Toggle Button, but I can not stop it !Who can help me? Thank you!
function togglebutton1_Callback(hObject, eventdata, handles)
% hObject    handle to togglebutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of togglebutton1
persistent value
value=get(hObject,'value');
if value==get(hObject,'Max')
  %  value_increase 
  for value=1:109 
    pause(0.2)
    handles.activex1.NeedleValue=value
    pause(0.2) 
end
else if value==get(hObject,'Min') 
        value=handles.activex1.NeedleValue
   % value_decrease  
   for value=value:-1:1
    pause(0.2)
    handles.activex1.NeedleValue=value
    pause(0.2)
    if value==1
        break
    end
    end
    end
end
0 Comments
Answers (2)
  Azzi Abdelmalek
      
      
 on 24 Oct 2012
        Think about adding another
value=get(hObject,'value');
if value==get(hObject,'Max')
inside the loop
0 Comments
  Walter Roberson
      
      
 on 24 Oct 2012
        You need to add
guidata(hObject, handles)
to update the version of handles that is seen by other routines.
0 Comments
See Also
Categories
				Find more on Function Creation in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

