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

1 回表示 (過去 30 日間)
Shivam Mishra
Shivam Mishra 2022 年 10 月 20 日
コメント済み: Rik 2022 年 10 月 20 日
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 件のコメント
Shivam Mishra
Shivam Mishra 2022 年 10 月 20 日
Your Code is working. Thankyou for this help.
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 Center および File ExchangeStartup and Shutdown についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by