How to use Timer Callback in App Designer?

69 ビュー (過去 30 日間)
MathWorks Support Team
MathWorks Support Team 2017 年 6 月 29 日
回答済み: MathWorks Support Team 2017 年 6 月 29 日
Using the App Designer, I would like to use the Timer callback within a callback section of the code. However, I am unable to reference functions from within the app using the function handle. How do I go about this? 

採用された回答

MathWorks Support Team
MathWorks Support Team 2017 年 6 月 29 日
In order to use the Timer Callback in App Designer, please follow the rules as follows-
1. Update the callback function signature to have four input arguments: 'app', 'obj', 'event', 'string_arg' as shown below:
 
function my_callback_fcn(app, obj, event, string_arg)
Note 'app' is the handle to the app object (this is necessary because the function is a method of the app), 'obj' is the handle to the timer, 'event' is the event data for the timer event, and 'string_arg' is the additional input argument specified by you.
2. Because the function my_callback_fcn is a method on the app object, you need to reference it using the 'app.' prefix.
To set the Timer object's properties like "t.StartFcn" and "t.StopFcn", please specify the callback function using the 'app.' prefix as shown below:
 
t.StartFcn = {@app.my_callback_fcn, 'my start message'};
t.StopFcn = {@app.my_callback_fcn, 'my stop message'};
 

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by