Why is my script not finishing when I run from command line?
Ältere Kommentare anzeigen
Hello,
I wrote a script to process a large data file and write a subset of data out to csv file. I run the file from command line as:
>matlab -nodisplay < script.m
When I first started running it a few weeks ago it completed in a few minutes but now it hangs and does not show it has completed when in fact it has. Can anyone tell me why? I am using an older version of matlab - R2013a (8.1.0.604) 64-bit (glnxa64).
Andre
Antworten (1)
Walter Roberson
am 21 Jun. 2016
Enclose the code in your script in a try/catch block, and at the end of your script put an explicit "quit"
Historically MATLAB did not always exit when it reached end of file on standard input, especially when it encountered an error that crashed the normal flow of control.
You are a bit safer to use
matlab -nodisplay -r "try; run('YourScript.m'); end; quit"
2 Kommentare
Andre
am 21 Jun. 2016
Walter Roberson
am 22 Jun. 2016
I suggest writing name to a log file so you can trace how far it is getting. In most programming languages I would say "and remember to flush the buffer", but in MATLAB that is automatically done unless you give special permissions when you open the file (either 'A' or 'W' instead of 'a' or 'w')
Kategorien
Mehr zu NetCDF finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!