Running Matlab Command From Tcl

2019-09-13 00:58发布

问题:

From my TCL script I like to open Matlab command window and display if its Matlab win32 or win64.

Therefore I use the following command:

exec {*}matlab -nodisplay -nosplash -nodesktop -r  "arch = computer; fprintf('%s \n', arch')";

However I keep getting error:

arch = computer; fprintf('%s 
                          |
Error: String is not terminated properly.

If I run the same in Matlab no issues.

Could some kindly advice.

Thanks

Anj.

回答1:

Tcl is substituting the \n before handing the command to matlab. Escape it:

exec matlab ... -r  "arch = computer; fprintf('%s \\n', arch')"

Or use braces

exec matlab ... -r  {arch = computer; fprintf('%s \n', arch')}


标签: matlab tcl