更新时间:2023-10-21 09:14:58
您可以在MATLAB中使用system
函数来执行Shell命令.由于您可以从批处理文件运行R,因此
You can use the system
function in MATLAB to execute shell commands. Since you can run R from batch files,
executed = system('R CMD BATCH path/script.R')
应该工作.请注意,无论您在MATLAB中的活动目录如何,path
都必须是R脚本的正确相对路径.如果系统命令成功执行(与R脚本成功执行不同,则executed
的计算结果将为0.)
should work. Note that path
will need to be the correct relative path to your R script from whatever your active directory in MATLAB is. executed
will evaluate as 0 if the system command executed successfully (which is not the same as the R script executing successfully).