running matlab function multiple times from windows command line
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
My matlab code is heavy in terms of memory and cpu cycles and takes days to finish. I need to re-run the code for 10 times. I am doing that using a matlab script, but the machine crashes due to out of memory error. Matlab help documentation recommends for such type of codes to save the work space and restart matlab frequently to avoid memory fragmentation. Therefore, I created the following simple windows script to automate restarting matlab:
@echo off
for /l %%x in (1, 1, 10) do (
matlab -nodisplay -nojvm -nosplash -nodesktop -r "Matlab_function(,);exit"
timeout 30 >nul
)
pause
It seems to me that still multiple instances of matlab are running together. My question is how to ensure that the next call to the matlab function do not happen until the current call is completely finished and the matlab command window is closed? any idea?
0 commentaires
Réponses (3)
Prasanth Sunkara
le 22 Jan 2018
Hello Mustafa, What I understand is you basically want to restart MATLAB every 30 min through a windows shell script. I would suggest you to modify the code a little as shown below: @Line 4: TIMEOUT /T 1800 /NOBREAK
-Prasanth
Benjamin Marechal
le 29 Mar 2018
Hello!
Just add '-wait' option to the command line: matlab -wait -nodisplay -nojvm -nosplash -nodesktop -r "Matlab_function(,);exit"
Without this option, your batch script will continue even if the matlab function hasn't finished.
You can check it by writing the command : matlab -help which gives :
-wait - MATLAB is started by a separate starter program
which normally launches MATLAB and then immediately
quits. Using the -wait option tells the starter
program not to quit until MATLAB has terminated.
This option is useful when you need to process the
the results from MATLAB in a script. The call to
MATLAB with this option will block the script from
continuing until the results are generated.
Using "-wait", you don't really need the timeout.
0 commentaires
Steven Lord
le 29 Mar 2018
When you say " I am doing that using a matlab script, but the machine crashes due to out of memory error. " do you mean MATLAB crashes, the machine on which you're running MATLAB crashes, or MATLAB throws an error indicating it is out of memory? In the first two cases, that obviously shouldn't happen and you should send any crash log you received from MATLAB to Technical Support for further investigation.
In the last case, how large a block of data are you trying to process? Are you using a release that supports datastore and tall, whose main purpose is to work with data so large it can't fit in memory as one piece? If you are using a release that includes tall and you want to try to see if it avoids the out of memory error, check the documentation included in your installation to make sure the functions you want to use are supported for tall. [The list of functions that support tall increases every release, so if you're not using the most recent release the list on the page to which I linked earlier will include functionality that won't work on your older release.]
0 commentaires
Voir également
Catégories
En savoir plus sur Performance and Memory dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!