How do I resolve "Error while evaluating TimerFcn for timer 'timer-1"?

29 Ansichten (letzte 30 Tage)
Gary Meehan
Gary Meehan am 22 Mär. 2024
Beantwortet: Gary Meehan am 2 Mai 2024
Hi:
While executing a Timer callback function, I encounter the following two error statements:
  1. Error while evaluating TimerFcn for timer 'timer-1'.
  2. Insufficient number of outputs from right hand side of equal sign to satisfy assignment.
Am I correct that this error is occurring in a MATLAB library function? If so, how do I locate where this assignment is taking place so that I can further debug the problem? I am using MATLAB 2022b.
For reference, this is the callback function:
function create_batch_file_and_run_Callback(~, ~, H) % =================================================================
create_batch_file_Callback([], [], H)
H = guidata(findall(0,'type','figure','tag','unicorn')); % since gets updated with batchFileName
H.IWantToCloseGUI = 1; % in create_batch_file_and_run_Callback
guidata(H.unicorn,H);
T = timer;
set(T,'StartDelay',2,'TimerFcn',['run_dr_suite_batch(''' H.batchFileName ''')']);
start(T);
myclosefcn(H.unicorn);
  2 Kommentare
Manikanta Aditya
Manikanta Aditya am 22 Mär. 2024
Bearbeitet: Manikanta Aditya am 22 Mär. 2024
function create_batch_file_and_run_Callback(~, ~, H)
% =================================================================
create_batch_file_Callback([], [], H)
H = guidata(findall(0,'type','figure','tag','unicorn')); % since gets updated with batchFileName
H.IWantToCloseGUI = 1; % in create_batch_file_and_run_Callback
guidata(H.unicorn, H);
T = timer;
set(T, 'StartDelay', 2, 'TimerFcn', ['run_dr_suite_batch(''' H.batchFileName ''');']);
start(T);
myclosefcn(H.unicorn);
end
This should resolve the "Insufficient number of outputs from right hand side of equal sign to satisfy assignment" error, as the string now represents a valid MATLAB expression.
Gary Meehan
Gary Meehan am 22 Mär. 2024
Thank you for the comment. I will implement that correction as you suggested. I should point out that I do not encounter the error I described above when executing the code on my company laptop. However, when I run the script on another system at work, that is when I encounter the error. I figure if I can locate the affected MATLAB library function, I can further diagnose the issue.

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Dinesh
Dinesh am 10 Apr. 2024
Hi Gary,
When you use a timer to execute a certain piece of code, then you might encounter the error "Error while evaluating TimerFcn for timer 'timer-1'" in a case where there is an error in the function that is being called after the timer expires. In this case, I believe that there might be an error with the "run_dr_suite_batch" function.
If you are able to execute the script in one machine successfully and not for the other system, then one of the most obvious reasons is the difference in MATLAB versions. It is recommended to always use the latest version. But, some of the older functionalities might've also been deprecated in newer versions, so keep an eye on that.
Here's a link that will give you detailed information for each release as to what are the new features, bugs fixed, etc: https://www.mathworks.com/help/matlab/release-notes.html

Gary Meehan
Gary Meehan am 2 Mai 2024
Hi Dinesh,
Rolling back to a previous version of MATLAB (2018b) resoved the issue. This in-house software that I am working with was developed ten years ago under 2015b. Apparently MATLAB functionality may have been deprecated, as you stated above. I will have to study the link to the release notes that you provided. Thank you,
-Gary

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by