Asterisk in MATLAB CLI Statements
1 view (last 30 days)
Show older comments
When passing statements to MATLAB CLI, asterisk * will be parsed by the shell, as listing files in the directory, instead of being parsed by MATLAB as multiplication.
Example: in terminal run this command
matlab -nodesktop -nosplash -r "1 * 2"
The output is
1 file1 file2 file3 2
where file1, file2, file3 are the items in the current directory.
Is there a way to prevent shell from parsing the statements?
0 Comments
Answers (1)
Harshit
on 15 Sep 2023
Hi,
I understand that you want to run a MATLAB script after it starts using the startup options but facing an issue while passing a multiplication symbol as it is treated as a way of listing the directory instead of a math symbol.
The cause of this issue is a bit unclear as the statement works fine for the latest version of MATLAB on Windows. It would be helpful if you could share the version of MATLAB and the OS platform that you're using.
As a workaround, you can encapsulate the math expression inside the "eval" function of MATLAB. For example:
matlab -nodesktop -nosplash -r "eval('1 * 2');"
Please note that the "eval" function expects a string datatype for the input. Hence, the expression must be a string or character vector.
To learn more about the eval function, you can refer to the following document:
I hope this helps.
Regards,
Harshit
0 Comments
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!