如何从Linux命令行调用MATLAB函数? [英] How to call MATLAB functions from the Linux command line?
本文介绍了如何从Linux命令行调用MATLAB函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
基本上我有一个 m
文件,看起来像
Basically I have an m
file which looks like
function Z=myfunc()
% Do some calculations
dlmwrite('result.out',Z,',');
end
我只是想从命令行执行它而不用进入MATLAB。我尝试了几个选项( -nodisplay
, -nodesktop
, -nojvm
, -r
等),没有一个工作。
I just want to execute it from the command line without getting into MATLAB. I tried several options (-nodisplay
, -nodesktop
, -nojvm
, -r
, etc.), none of them worked. I end up getting into MATLAB and have to type "quit" to exit.
这是什么解决方案?
推荐答案
MATLAB 可以运行脚本,但不能运行函数命令行。这是我所做的:
MATLAB can run scripts, but not functions from the command line. This is what I do:
文件 matlab_batcher.sh
:
#!/bin/sh
matlab_exec=matlab
X="${1}(${2})"
echo ${X} > matlab_command_${2}.m
cat matlab_command_${2}.m
${matlab_exec} -nojvm -nodisplay -nosplash < matlab_command_${2}.m
rm matlab_command_${2}.m
输入:
./matlab_batcher.sh myfunction myinput
这篇关于如何从Linux命令行调用MATLAB函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文