I want to run a script on windows dos terminal where the script will display "Hello world" to the terminal I executed this from e.g.
matlab.exe -nosplash -nodesktop -nojvm -wait -r printToCommandLine.m
Where printToCommandLine.m contains:
system(sprintf('echo Hello world'));
but it only prints to the matlab command window that gets generated when executing the script
First, I am not shure, if the syntax has changed, but I have to call the script without the file extension '.m':
matlab.exe -nosplash -nodesktop -nojvm -wait -r printToCommandLine
Otherwise I will get an error within MATLAB.
Second, this is just a work around, but you can print your current command line output to a log file e.g. 'log.txt' using
matlab.exe -nosplash -nodesktop -nojvm -wait -logfile "log.txt" -r printToCommandLine
The log file will be updated at runtime. To test this, I created a small example script and had a look how 'log.txt' changes during execution:
disp('Script execution started. Waiting 10 seconds...')
pause(10)
disp('...waited 10 seconds.');
This is not exactly what you wanted but it gives you the chance to get actual information about the current command line output during your execution (in a text file).
We use this for automated (remote) testing to print our MATLAB command line output to the console after the tests pass with
type log.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With