用matlab连接从netbeans

时间:2014-01-28 09:35:35

标签: java matlab netbeans

我想从netbeans连接到Matlab并读取一些图像文件并进行图像处理。 它在上个月工作正常,我做了我的最后研究的所有测试,它工作得很好。 这是我与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);

                    }

现在它不能从MatlabProxy proxy = factory.getProxy()运行;声明 它打开了Matlab并且发出了一个巨大的错误,

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)...

有人可以尽快给出一个想法。 感谢

0 个答案:

没有答案