我试图使用R.matlab
软件包,但坦率地说我无法启动Matlab服务器。
我在OS X 10.11.5上使用Matlab R2015b。
在R中我得到
> Matlab()
[1] "Matlab: The MATLAB host is 'localhost' and communication goes via port 9999. Objects are passed via the local file system (remote=FALSE). The connection to the MATLAB server is closed (not opened)."
> Matlab$startServer()
[1] 0
sh: matlab: command not found
但是在终端中,我确实可以使用matlab
命令启动Matlab。
也在终端内
matlab -nodesktop -nosplash -r MatlabServer
结果
Undefined function or variable 'MatlabServer'.
>>
答案 0 :(得分:2)
我设法修复它从终端运行matlab。您只需转到用户个人资料~/usr/your_nickame
并在任何编辑器中编辑文件 .bash_profile (并保存!)并添加
alias matlab=“/Applications/MATLAB_R2015a.app/bin/matlab”
终端知道matlab的意思,在哪里找到它并执行它。它会使别名永久化。如果从终端
启动服务器,则可以选择此选项如果你想直接从R启动它,我设法通过设置 matlab 命令运行来使其工作:
options(matlab="/Applications/MATLAB_R2015a.app/bin/matlab")
然后通常的作品:
require(R.matlab)
Matlab$startServer()
matlab <- Matlab()
isOpen <- open(matlab)
< M A T L A B (R) >
Copyright 1984-2015 The MathWorks, Inc.
R2015a (8.5.0.197613) 64-bit (maci64)
February 12, 2015
To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.
Running MatlabServer v3.5.9-9000
MATLAB v7.x or higher detected.
Saving with option -V6.
Added InputStreamByteWrapper to dynamic Java CLASSPATH.
----------------------
MATLAB server started!
----------------------
MATLAB working directory: /Users/air/Desktop/Dissertation/myPack/finalPack
Trying to open server socket (port 9999)...Error using MatlabServer (line 130)
Java exception occurred:
java.net.BindException: Address already in use
at java.net.PlainSocketImpl.socketBind(Native Method)
at
java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
at java.net.ServerSocket.bind(ServerSocket.java:376)
at java.net.ServerSocket.<init>(ServerSocket.java:237)
at java.net.ServerSocket.<init>(ServerSocket.java:128)
>>
>