count a loop when button is pushed
5 次查看(过去 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!