I have a matlab script xxx.m that runs fine within matlab's GUI command window, creating a couple of subdirectories and outputting some data into those subdirectories.

When i load Matlab at the bash command line without the GUI, and then try to call the script from a bash command line using

$ matlab -nodisplay -nodesktop -r "run xxx.m"

the script appears to run, but only creates the required output directories for the script's outputs without producing any of the actual output, and flags several errors within the script that do not exist when the script is run from the Matlab GUI command window.

Is this problem something to do with setting paths or environment variables?

(I'm quite used to basic bash scripting so I was hoping i could run pre-written matlab.m scripts seamlessly inside bash).

  • What are the errors that the script produces? Edit the text to include these, do not put them into comments.
    – Kusalananda
    Mar 8, 2018 at 6:24

1 Answer 1


Edit: deleted previous response. I misunderstood your question.

It may be helpful you posted a stripped down version of the problematic script that recreates the problem you are having. I use Matlab from the terminal all the time in a similar manner to what you describe (creating directories and writing to them etc).

  • 1
    What makes you believe that the OP is having trouble capturing the output from their command? Apr 23, 2018 at 2:17
  • Thanks and fixed. I previously thought that "actual output" OP meant output from OPs command.
    – avgn
    Apr 23, 2018 at 5:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .