Matlab的运行使用.bat文件在Windows命令逐个 [英] run Matlab commands one by one on windows using .bat file
问题描述
我试图运行在不同的文件的功能;我想用bash类似的脚本来做到这一点。当我看着在网络上;我发现我可以使用.bat文件。
I am trying to run a function on different files; I would like to use Bash-Like script to do that. When I looked on the web; I found that I can use .bat file.
我的.bat文件包含此
My .bat file contains this
matlab -bodesktop -nosplash -r myFunction('input_1.txt')
matlab -bodesktop -nosplash -r myFunction('input_2.txt')
matlab -bodesktop -nosplash -r myFunction('input_3.txt')
matlab -bodesktop -nosplash -r myFunction('input_4.txt')
matlab -bodesktop -nosplash -r myFunction('input_5.txt')
当我双击该文件,似乎这些命令上并行运行,从而,使得PC崩溃。
When I double click the file, it seems that these commands are running on parallel, which, makes the PC to crash.
我看着Matlab的论坛替代解决方案,但不能和我一起工作。
I looked on Matlab Forum for alternative solutions, but couldn't work with me
另一种选择,我发现:
start -wait matlab -bodesktop -nosplash -r "myFunction('input_1.txt');exit"
..
任何人使用此之前?
Anyone used this before ?
推荐答案
有两种MATLAB二进制文件,有一个 matlabroot / bin中
另外在 matlabroot /斌/ Win64中/
。第一个是唯一的一个启动应用程序,只要主应用程序成功启动其通常终止。为了保持开放,直到主应用程序终止,你必须使用你的 matlab.exe
(不是 -wait
选项与混淆的启动-wait
选项,机器人可以一起使用)。
There are two matlab binaries, one matlabroot/bin
the other in matlabroot/bin/win64/
. The first one is only a launcher application which typically terminates as soon as the main application is started successfully. To keep it open until the main application terminates you have to use the -wait
option with your matlab.exe
(not to be confused with the start -wait
option, bot can be used together).
在您的情况下可以尝试:
In your case try:
matlab -wait -nodesktop -nosplash -r myFunction('input_1.txt')
(我假设你打算使用nodesktop)。
(I assume you intended to use "nodesktop").
所有的启动窗口参数的解释在这里的文档。 (您必须单击选项1 ...... optionN展开相关章节。)
All start parameters for windows are explained here in the documentation. (You have to click "option1...optionN" to expand the relevant section.)
这篇关于Matlab的运行使用.bat文件在Windows命令逐个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!