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.
我试图在不同的文件上运行一个函数;我想使用Bash-Like脚本来做到这一点。当我在网上看时;我发现我可以使用.bat文件。
My .bat file contains this
我的.bat文件包含这个
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')
When I double click the file, it seems that these commands are running on parallel, which, makes the PC to crash.
当我双击该文件时,似乎这些命令并行运行,这使PC崩溃。
I looked on Matlab Forum for alternative solutions, but couldn't work with me
我在Matlab论坛上寻找替代解决方案,但无法与我合作
Another option I found:
我找到的另一种选择:
start -wait matlab -bodesktop -nosplash -r "myFunction('input_1.txt');exit"
..
Anyone used this before ?
以前有人用这个吗?
2 个解决方案
#1
1
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).
有两个matlab二进制文件,一个是matlabroot / bin,另一个是matlabroot / bin / win64 /。第一个只是一个启动器应用程序,通常在主应用程序成功启动后立即终止。要在主应用程序终止之前保持打开状态,您必须在matlab.exe中使用-wait选项(不要与start -wait选项混淆,bot可以一起使用)。
In your case try:
在你的情况下尝试:
matlab -wait -nodesktop -nosplash -r myFunction('input_1.txt')
(I assume you intended to use "nodesktop").
(我假设您打算使用“nodesktop”)。
All start parameters for windows are explained here in the documentation. (You have to click "option1...optionN" to expand the relevant section.)
窗口的所有启动参数都在文档中说明。 (您必须单击“option1 ... optionN”以展开相关部分。)
#2
-2
First check that you have the option spelled correctly. Click here for the options.
首先检查您是否正确拼写了拼写选项。单击此处查看选项。
Try this:
matlab -wait -nodesktop -nosplash -r "myFunction('input_1.txt')"
matlab -wait -nodesktop -nosplash -r“myFunction('input_1.txt')”
Edit:
By default, when you call the matlab command from a script, the command starts MATLAB and then immediately executes the next statements in the script. The -wait option pauses the script until MATLAB terminates.
默认情况下,当您从脚本调用matlab命令时,该命令将启动MATLAB,然后立即执行脚本中的下一个语句。 -wait选项暂停脚本,直到MATLAB终止。
Use the -wait option in a startup script to process the results from MATLAB. Calling MATLAB with this option blocks the script from continuing until the results are generated.
在启动脚本中使用-wait选项来处理MATLAB的结果。使用此选项调用MATLAB会阻止脚本继续运行,直到生成结果。
#1
1
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).
有两个matlab二进制文件,一个是matlabroot / bin,另一个是matlabroot / bin / win64 /。第一个只是一个启动器应用程序,通常在主应用程序成功启动后立即终止。要在主应用程序终止之前保持打开状态,您必须在matlab.exe中使用-wait选项(不要与start -wait选项混淆,bot可以一起使用)。
In your case try:
在你的情况下尝试:
matlab -wait -nodesktop -nosplash -r myFunction('input_1.txt')
(I assume you intended to use "nodesktop").
(我假设您打算使用“nodesktop”)。
All start parameters for windows are explained here in the documentation. (You have to click "option1...optionN" to expand the relevant section.)
窗口的所有启动参数都在文档中说明。 (您必须单击“option1 ... optionN”以展开相关部分。)
#2
-2
First check that you have the option spelled correctly. Click here for the options.
首先检查您是否正确拼写了拼写选项。单击此处查看选项。
Try this:
matlab -wait -nodesktop -nosplash -r "myFunction('input_1.txt')"
matlab -wait -nodesktop -nosplash -r“myFunction('input_1.txt')”
Edit:
By default, when you call the matlab command from a script, the command starts MATLAB and then immediately executes the next statements in the script. The -wait option pauses the script until MATLAB terminates.
默认情况下,当您从脚本调用matlab命令时,该命令将启动MATLAB,然后立即执行脚本中的下一个语句。 -wait选项暂停脚本,直到MATLAB终止。
Use the -wait option in a startup script to process the results from MATLAB. Calling MATLAB with this option blocks the script from continuing until the results are generated.
在启动脚本中使用-wait选项来处理MATLAB的结果。使用此选项调用MATLAB会阻止脚本继续运行,直到生成结果。