Launching code from MS scheduler...code starts before initialization has finished

2 次查看(过去 30 天)
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?

回答(1 个)

Pratyush Swain
Pratyush Swain 2025-1-3
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.

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by