필터 지우기
필터 지우기

PushButton HitCounter / simple question

조회 수: 2 (최근 30일)
Max Müller
Max Müller 2014년 7월 17일
답변: Sara 2014년 7월 17일
hey Guys,
I want to create a program, which includes a Code, that counts how many times u clicked on a button. My Thought was....use x = x +1 but where do I define x as 0 ?
here, it wont work
x = 0
function pushbutton8_Callback(hObject, eventdata, handles)
x = x +1
.......
here, it will always set x back to 0
function pushbutton8_Callback(hObject, eventdata, handles)
x = 0
x = x +1
PS: Sorry for that stupied Question

채택된 답변

Sara
Sara 2014년 7월 17일
Add
handles.counter = 0;
in the GUI opening function. Then in the pushbutton, increment the counter
handles.counter = handles.counter + 1;
Remember to add
guidata(hObject, handles);
at the end of the opening function and of the pushbutton callback.

추가 답변 (0개)

카테고리

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