How do you run Matlab in batch mode in R2021b Update 2?
4 次查看(过去 30 天)
显示 更早的评论
Hi,
I would like to run a bash script in matlab without GUI.
In version R2020b, it was working, now (R2021b Update 2) it is not.
xy@host:~/dev/$ matlab -batch "compile_lib.sh"
MATLAB is selecting SOFTWARE OPENGL rendering.
< M A T L A B (R) >
Copyright 1984-2021 The MathWorks, Inc.
R2021b Update 2 (9.11.0.1837725) 64-bit (glnxa64)
December 14, 2021
To get started, type doc.
For product information, visit www.mathworks.com.
>> exit
Also tried: matlab -nodisplay -nosplash -nodesktop -r "run('compile_lib.sh');exit;"
But the output is the same as above.
Could you tell me what is the correct method to do this?
1 个评论
Jan
2022-2-15
The run() command required the name of a Matlab script. "compile_lib.sh" does not sound like a Matlab script file name.
回答(1 个)
Dinesh
2023-12-29
Hi Jean,
To run a bash script, you don't need MATLAB. You can just open terminal and execute the following command:
bash compile_lib.sh
If the script is a MATLAB script (.m file), then you would execute it without opening the GUI using the "run" function. The following is the documentation link:
If you still want to execute bash script using MATLAB only, then you can use the "system" function to do it:
matlab -nodisplay -nosplash -nodesktop -r "system('bash compile_lib.sh');exit;"
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!