Error message when using timers in AppDesigner after a few seconds running
23 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Walter Roberson
am 12 Jul. 2024 um 22:29
Bearbeitet: Walter Roberson
am 12 Jul. 2024 um 22:30
'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.
2 Kommentare
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!