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

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?

Risposte (1)

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.

Categorie

Prodotti

Release

R2019a

Richiesto:

il 10 Dic 2024

Risposto:

il 3 Gen 2025

Community Treasure Hunt

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

Start Hunting!

Translated by