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 Comment

Where is your function located?
Try removing the app. before Test?
tt.TimerFcn = {@Test,app,10};

Sign in to comment.

 Accepted Answer

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

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Asked:

on 24 Jun 2022

Answered:

Jan
on 24 Jun 2022

Community Treasure Hunt

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

Start Hunting!