从终端/ JAVA在MATLAB改变目录 [英] Change Directory in MATLAB from Terminal/JAVA

查看:242
本文介绍了从终端/ JAVA在MATLAB改变目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够改变MATLAB的工作目录不与命令窗口交互。我是从一个Java应用程序启动MATLAB。现在唯一的解决办法我已经拿出正在关闭MATLAB,从Java改变目录,并重新发动。有没有从Java发送MATLAB的CD命令的一些简化的方法吗?在命令行这样做也将工作,因为我可以用getRuntime()。EXEC(命令)

I need to be able to change the working directory in MATLAB without interacting with the command window. I'm launching MATLAB from a Java application. Right now the only solution I've come up with is closing MATLAB, changing directory from JAVA and relaunching. Is there some streamlined way to send MATLAB the 'cd' command from JAVA? Doing so from the command-line would also work, since I could use getRuntime().exec(command)

谢谢!

推荐答案

您可以如果你使用同一个JVM Matlab的(如果没有的话我也没办法)做到这一点使用JMI。这里是不是这么多的在线信息(它的 WAY 的无证/不支持)。谷歌或阅读这样的: http://www.cs.virginia.edu/怀特豪斯〜/ MATLAB / JavaMatlab.html 。总之,你需要包括Matlab的相关JAR文件,然后使用com.mathworks.jmi.Matlab的功能。例如:

You can do this using JMI if you're using the same JVM as Matlab (if not then I have no idea). There is not much online info about this (it's WAY undocumented/unsupported). Google it or read this: http://www.cs.virginia.edu/~whitehouse/matlab/JavaMatlab.html. In short, you need to include Matlab's relevant JAR file and then use com.mathworks.jmi.Matlab's functionality. For example:

Matlab.evalConsoleOutput(CD('C:\\ Program Files文件\\'));

亚伊尔奥特曼
http://UndocumentedMatlab.com

这篇关于从终端/ JAVA在MATLAB改变目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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