When I run matlab -nodesktop -r "run myscript" a Matlab command window pops up and the output is there, but I would like the output to be directed to the unix console. So how do I get a Matlab script ran from a Unix console to output to the Unix console?
-
also look at no jvm and no splashvish– vish2013-11-13 17:50:02 +00:00Commented Nov 13, 2013 at 17:50
Add a comment
|
1 Answer
To output data to console (better to say stdout) you can use MATLAB function fprintf() and run it:
user@host $ matlab -nodesktop -r "run new.m; quit"
new.m:
noise_gain = 0.5;
filter_length = 128;
fprintf('*******************************************************************\n');
fprintf('** Starting processing for noise level %f and filter length %d**\n',noise_gain,filter_length);
fprintf('*******************************************************************\n');
It gives output:
*******************************************************************
** Starting processing for noise level 0.500000 and filter length 128**
*******************************************************************
Also you can send output to file (out.txt):
user@host $ matlab -nodesktop -r "run new.m; quit"> out.txt; cat out.txt
< M A T L A B (R) >
Copyright 1984-2012 The MathWorks, Inc.
R2012b (8.0.0.783) 64-bit (glnxa64)
August 22, 2012
To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.
*******************************************************************
** Starting processing for noise level 0.500000 and filter length 128**
*******************************************************************