Borrar filtros
Borrar filtros

Asterisk in MATLAB CLI Statements

6 visualizaciones (últimos 30 días)
Josh Zhang
Josh Zhang el 2 de Abr. de 2022
Respondida: Harshit el 15 de Sept. de 2023
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?

Respuestas (1)

Harshit
Harshit el 15 de Sept. de 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

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by