1

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?

1
  • also look at no jvm and no splash Commented Nov 13, 2013 at 17:50

1 Answer 1

2

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**
*******************************************************************
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.