count a loop when button is pushed
조회 수: 6 (최근 30일)
이전 댓글 표시
hi,
i have a button with which i start a function. in the function there should be a for loop that counts up every time the button is clicked. what is the best way to solve this?
Best regards
댓글 수: 0
답변 (2개)
Mike
2021년 4월 12일
All controls come with a "UserData" field. I would use that, In "startupFcn" initialize to zero
app.Button.UserData = 0
Then in the button pushed function
app.Button.UserData = app.Button.UserData + 1;
댓글 수: 0
Image Analyst
2021년 4월 12일
See attached GUI. When you press the Go button, it counts up and put the result into a text label on the GUI. When you press the Stop button, it stops.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!