How to enable a pushbutton after five clicks on another pushbutton?
Afficher commentaires plus anciens
I have pushbutton1 to save values and pushbutton2 to plot this values. pushbutton2 is disabled, I want to enable it after clicking pushbutton1 five times.
Réponses (1)
Image Analyst
le 30 Avr 2017
Modifié(e) : Image Analyst
le 30 Avr 2017
In the opening function for your GUI, set the UserData property to 0 and disable pushbutton2:
handles.pushbutton1.UserData = 0; % No button presses so far.
handles.pushbutton2.Enable = 'off'; % Disable pushbutton 2 at the start.
Then in the pushbutton1 callback increment it and enable pushbutton 2 if the count is 5.
handles.pushbutton1.UserData = handles.pushbutton1.UserData + 1;
if handles.pushbutton1.UserData == 5
handles.pushbutton1.UserData = 0; % Reset count to 0.
handles.pushbutton2.Enable = 'on'; % Enable pushbutton 2.
end
I'm attaching a simple demo that works.
3 commentaires
zeyneb khalili
le 30 Avr 2017
Image Analyst
le 30 Avr 2017
Modifié(e) : Image Analyst
le 30 Avr 2017
Try the attached demo. It works for me. (I edited the answer above to also include the same files.)
zeyneb khalili
le 30 Avr 2017
Catégories
En savoir plus sur Vehicle Dynamics Blockset dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!