Error message when using timers in AppDesigner after a few seconds running
조회 수: 23 (최근 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일 22:29
편집: Walter Roberson
2024년 7월 12일 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.
참고 항목
카테고리
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!