Connecting Mat lab from Netbeans

5 次查看(过去 30 天)
Malithi
Malithi 2014-1-28
评论: Ned Twigg 2015-10-20
Hi, I want to connect to Matlab from netbeans and read some image files and do image processing. It works fine in last month,i did all the testing for my final reaserch and it worked fine. This is my cording to connect with Matlab,
MatlabProxyFactoryOptions options = new MatlabProxyFactoryOptions.Builder().setUsePreviouslyControlledSession(true).build();
MatlabProxyFactory factory = new MatlabProxyFactory(options);
MatlabProxy proxy=factory.getProxy();
// call builtin function
String curr="";
for (int i = 0; i < r.fileread(path).length; i++) {
curr=r.fileread(path)[i]+"\\*.bmp";
String out=r.fileread(path)[i]+".txt";
String newfile=r.fileread(path)[i]+"_new.txt";
//execute the addapth path command in matlab
proxy.eval("addpath('D:\\finalwk')");
//execute user defined functions
proxy.feval("Untitled",r.fileread(path)[i],curr,out);
proxy.feval("uni",out,newfile);
}
Now it dose not run from MatlabProxy proxy=factory.getProxy(); statement it opens Matlab and and gives a huge error,
Reconnecting to this session of MATLAB will not be possible matlabcontrol.MatlabConnectionException: Could not register this session of MATLAB at matlabcontrol.MatlabBroadcaster.bindSession(MatlabBroadcaster.java:144) at matlabcontrol.MatlabBroadcaster.broadcast(MatlabBroadcaster.java:92) at matlabcontrol.MatlabConnector$EstablishConnectionRunnable.run(MatlabConnector.java:209) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection timed out: connect at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)...
Can Some one give an idea as soon as possible. Thanks
  1 个评论
Ned Twigg
Ned Twigg 2015-10-20
Hi there! It's probably too late to help you with this particular project, but you might like to know about MatConsoleCtl.
matlabcontrol is fantastic, but it hasn't been updated in a couple years.
I've created a binary-compatible fork on GitHub which is actively maintained called MatConsoleCtl.
Relative to matlabcontrol, it contains these changes
  • available on Maven Central as com.diffplug.matsim:matconsolectl
  • a way to connect to an existing MATLAB session by copy-pasting a string of text to the MATLAB console
  • more descriptive error messages in exceptions
  • compatibility with OSGi classloaders
  • fixed all compiler warnings
  • fixed several tricky bugs which were found by FindBugs
I'm happy to accept any GitHub Issues or Pull-Requests, and I'll be keeping it up-to-date and tested.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Import, Export, and Conversion 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by