Error message when using timers in AppDesigner after a few seconds running
7 次查看(过去 30 天)
显示 更早的评论
I'm quite new to using timers in Matlab, and currently I'm running a project that will need them to continuously update some info in our App Designer window. The problem is, I followed the instructions in this tutorial from Matlab and initially my timer and callback function work normally. But after some time of it running I receive the following error message:
Error while evaluating TimerFcn for timer 'timer-1'
Not enough input arguments.
I currently initialize my timer in the startupFcn of the app as:
function startupFcn(app)
global params
app.textbox_Log.Value = {'Start'};
app.timerCounter1sec = 0;
app.timerCounter10sec = 0;
app.logStatus = 'running';
app.timer500ms = timer('Period',0.5,...
'ExecutionMode', 'fixedSpacing', ...
'TasksToExecute', Inf, ...
'BusyMode', 'drop', ...
'TimerFcn', @app.timerTest);
start(app.timer500ms);
updateJobList(app, params);
fillJobsTable(app, params);
end
And my callback function is defined as the following (I will omit the code for now since I don't think it's that important right now):
function timerTest(app,~,~)
% Function details...
end
Can someone help me with this? I have no clue of what is happening to throw this error in the timer, even considering that it works for around 3-4 seconds before breaking.
0 个评论
回答(1 个)
Walter Roberson
2024-7-12
编辑:Walter Roberson
2024-7-12
'TimerFcn', @app.timerTest);
the timer will be created with a TimerFcn that is a function handle to a function that expects two parameters.
function timerTest(app,~,~)
You define the function as expecting three parameters.
Note that timer functions are not passed app by default.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!