필터 지우기
필터 지우기

How to enable a pushbutton after five clicks on another pushbutton?

조회 수: 1 (최근 30일)
zeyneb khalili
zeyneb khalili 2017년 4월 29일
댓글: zeyneb khalili 2017년 4월 30일
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.

답변 (1개)

Image Analyst
Image Analyst 2017년 4월 30일
편집: Image Analyst 2017년 4월 30일
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
Image Analyst
Image Analyst 2017년 4월 30일
편집: Image Analyst 2017년 4월 30일
Try the attached demo. It works for me. (I edited the answer above to also include the same files.)
zeyneb khalili
zeyneb khalili 2017년 4월 30일
Thanks. the problem is that this assignement (handles.pushbutton1.UserData = 0) doesn't work in my matlab r2009a.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by