matlab -batch always failed with: | Error: Invalid use of operator.

8 Ansichten (letzte 30 Tage)
Ye Cao
Ye Cao am 14 Jul. 2021
Bearbeitet: Jan am 14 Jul. 2021
Following Matlab's manual, I run Matlab with: matlab -batch ./hello.m or matlab -batch "./hello.m".
However, there is an error: | Error: Invalid use of operator.
The hello.m is just an oneline script: fprintf("hello\n");
Can you tell me what is the problem here?
Thanks!

Akzeptierte Antwort

Jan
Jan am 14 Jul. 2021
Bearbeitet: Jan am 14 Jul. 2021
The string after the -batch argument must contain a Matlab command. "./hello.m" is not a Matlab command, because "./" is the elementwise division. You do not specify paths of Matlab functions, if you call them. The appended ".m" let Matlab assume that "hello" is a struct.
Try this instead:
matlab -batch "hello"
Remember to store the file hello.m in a folder, which is included in the Matlab path.

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by