How to perform different task on one single button pushed one by one to perform one by one task

조회 수: 3 (최근 30일)
I want to press a single button in app designer multiple times and each time same button perform different task.

답변 (1개)

Rik
Rik 2022년 10월 20일
You can use a persistent variable to keep track of the number of times the callback was called:
persistent NumberOfCalls
if isempty(NumberOfCalls),NumberOfCalls=0;end
NumberOfCalls = NumberOfCalls+1;
TotalNumberOfTasks = 3;
NumberOfCalls = mod(NumberOfCalls,TotalNumberOfTasks);
switch NumberOfCalls
case 1
% do something
case 2
% do something else
case 0
% do something different
end
  댓글 수: 5
Rik
Rik 2022년 10월 20일
You're welcome. If my answer helped you solve the question, please consider marking it as accepted answer. If you still have remaining issues, please post a comment with your remaining questions.

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

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by