
Launching code from MS scheduler...code starts before initialization has finished
2 views (last 30 days)
Show older comments
I launch some Matlab code from MS scheduler at a given time, and it starts the script before Matlab initilaization has finished. Is there any way of ensuring the initalization is finished before the code is run?
0 Comments
Answers (1)
Pratyush Swain
on 3 Jan 2025
Hi David,
I am assuming here by MATLAB initialization, you are referring to the loading up of the MATLAB GUI. If your script is running before MATLAB initialization has finished, you can consider the following workarounds:
1.If your script does not require loading up of MATLAB, consider running script in a non interactive manner using batch processing.This can help manage initialization overhead and ensure script is run in separate session.
To perform this in the Microsoft Task Scheduler, under the 'Actions' tab set the program to MATLAB exceutable file and under arguments add: batch "run('path\to\your_script.m')".
Please refer to the snapshot below:

2. You can add a delay at the beginning of your main script which might allow MATLAB to initialize completely before executing the rest of the script.
% ----- script/code file ----- %
pause(5); % Wait for 5 seconds
% ----- Rest of your script --- %
Hope this helps.
0 Comments
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!