在脚本中,如何知道Matlab是运行在互动(槽emacs)还是批量运行? [英] In a script, how to known if Matlab is running in Interactive (trough emacs) or in Batch?

查看:145
本文介绍了在脚本中,如何知道Matlab是运行在互动(槽emacs)还是批量运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我的Matlab脚本中,我想区分脚本在交互式谷歌的matlab模式或批处理中运行的情况。按照Matlab网站上的说明运行, http://www.mathworks.com/支持/解决方案/ en / data / 1-15HNG



例如,通过一个变量来做这样的想法:

  if(SCRIPT_RUNNING_IN_BATCH == 1)
do_this;
end

有没有办法这样做?

解决方案

我使用以下内容:

  function retval = isCommandWindowOpen ()
jDesktop = com.mathworks.mde.desk.MLDesktop.getInstance;
retval =〜isempty(jDesktop.getClient('Command Window'));
end

如前所述,这是从此处


In my Matlab script I would like to discriminate the case where the script is run in Interactive trough emacs matlab mode or in Batch.

By running in Batch I mean running as explained on Matlab website here http://www.mathworks.com/support/solutions/en/data/1-15HNG.

For example trough a variable for doing think like this:

if (SCRIPT_RUNNING_IN_BATCH==1)
  do_this;
end

Is there a way to doing this?

解决方案

I use the following:

function retval = isCommandWindowOpen()
    jDesktop = com.mathworks.mde.desk.MLDesktop.getInstance;
    retval = ~isempty(jDesktop.getClient('Command Window'));
end

as mentioned earlier, this is a copy from here

这篇关于在脚本中,如何知道Matlab是运行在互动(槽emacs)还是批量运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆