how to make timer callback function?

Hi
I tried making a timer callback function on app designer like this, but it didn't work. What is the problem?
function Test(obj,event,app,variable)
disp(variable);
disp(app.something);
end
tt = timer('Name','Test','Period',1,'ExecutionMode','fixedSpacing','BusyMode','drop');
tt.TimerFcn = {@app.Test,app,10};
start(tt);

1 件のコメント

Kevin Holly
Kevin Holly 2022 年 6 月 24 日
Where is your function located?
Try removing the app. before Test?
tt.TimerFcn = {@Test,app,10};

サインインしてコメントする。

 採用された回答

Jan
Jan 2022 年 6 月 24 日

0 投票

app.something = 'hello';
tt = timer('Name','Test','Period',1, ...
'ExecutionMode','fixedSpacing','BusyMode','drop');
tt.TimerFcn = {@Test, app, 10}; % 1st two inputs inserted automatically
start(tt);
function Test(obj, event, app, variable)
disp(variable);
disp(app.something);
end

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDevelop Apps Using App Designer についてさらに検索

質問済み:

2022 年 6 月 24 日

回答済み:

Jan
2022 年 6 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by