0

My machine: ubuntu 18.04, run with python 3.7.1 and matlab 18b, in python it is:

import os

os.system('matlab -nojvm -nodisplay -nosplash -r "Mymat;quit;"')

and in Mymat.m it is

function X2 = TFOCS_LS()
  a = 1; b = 2;
  X2 = a+b;
end

Even I set that -nodisplay flag, in the terminal it will still print something like below in the command line. How to suppress this information printout?

                                                         < M A T L A B (R) >
                                                Copyright 1984-2018 The MathWorks, Inc.
                                           R2018b Update 2 (9.5.0.1033004) 64-bit (glnxa64)
                                                            January 5, 2019

 
For online documentation, see https://www.mathworks.com/support
For product information, visit www.mathworks.com.

user21
  • 329
  • 2
  • 15
  • 1
    `-nodisplay` turns off the graphics display, has nothing to do with terminal I/O. I don’t think it is possible to turn off the MATLAB welcome message. – Cris Luengo Aug 22 '20 at 06:53
  • 1
    I tried this on 18a and I don't see the MATLAB welcome message – Paolo Aug 22 '20 at 10:24
  • 1
    That is not what those command-line args do, but you can pipe the stdout from the Matlab process into /dev/null. This won't help if you need the stdout to view your results. – Mansoor Aug 22 '20 at 10:48

1 Answers1

1

As stated in the comments -nodisplay is just to run Matlab headless without graphical output and does not disable the commandline or shell output.

-If you don't want any output at all from matlab you can use &>/dev/null as stated here to dump the output or write it to a file.

-If you want to remove the Matlab "welcome Header" forever, you can edit the matlabrc.m file and remove it there, wich might be against the matlab Terms & Conditions. For more information please look here.

-A 3rd Option is to remove the Header using the tail Function of Linux like described here.

This is not part of your Question, but could be handy if you plan to use more Matlab Funcions in Python: There is a Matlab Engine API, that makes it possible to run Matlab funcions without using system. (And also is a lot faster, as you don't need to start Matlab every time you want to call a Matlab function)

HannesM
  • 24
  • 3