how to make timer callback function?

조회 수: 3 (최근 30일)
Jae-Hee Park
Jae-Hee Park 2022년 6월 24일
답변: Jan 2022년 6월 24일
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일
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개)

카테고리

Help CenterFile Exchange에서 Develop 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