Asterisk in MATLAB CLI Statements
    11 ビュー (過去 30 日間)
  
       古いコメントを表示
    
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 件のコメント
回答 (1 件)
  Harshit
    
 2023 年 9 月 15 日
        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 件のコメント
参考
カテゴリ
				Help Center および File Exchange で Startup and Shutdown についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

