0

I have a matlab function checkMembraneSpline.m, and I want to run this in the command line using the matlab command. I tried the following

matlab -r -nodisplay -nojvm "checkMembraneSpline(10,1000,'',100,500,2.5); catch; end; quit"

which returns this cryptic error:

/opt/apps/rhel7/matlabR2019a/bin/matlab: eval: line 1734: syntax error near unexpected token `('
/opt/apps/rhel7/matlabR2019a/bin/matlab: eval: line 1734: `exec  "/admin/apps/rhel7/matlabR2019a/bin/glnxa64/MATLAB"  -r "-nodisplay" checkMembraneSpline(10,1000,'',100,500,2.5); catch; end; quit -nojvm'

However, when I launch matlab by doing matlab -nojvm -nodisplay and running the function from there by

>>> checkMembraneSpline(10,1000,'',100,500,2.5)

it works. I suspected it was something to do with the quotation marks, but switching " with ' also doesn't work. What am I missing?

0

1 Answer 1

2

The statement has to come right after the -r switch:

matlab -nodisplay -nojvm -r "checkMembraneSpline(10,1000,'',100,500,2.5); catch; end; quit"

If you have a newer version of MATLAB, use the -batch switch instead:

matlab -nojvm -batch "checkMembraneSpline(10,1000,'',100,500,2.5);"

With this new switch you don’t need to have an exit call, it always quits after competing the statement. Therefore, it is also not necessary to catch errors. Output is put into the terminal by default. Much simpler!

Reference: https://www.mathworks.com/help/matlab/ref/matlablinux.html

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.