Joonbum Joonbum - 3 months ago 18
Java Question

How to call Matlab functions from Java using matlabcontrol without starting new session every time?

I am using matlabcontrol to call Matlab functions from Java

My code works well, but it opens new Matlab session whenever I run my code in Java.
I edited according to Javadoc, but I guess I missed something.

I also tried this with/without 'proxy.disconnect()', but it still opens new Matlab session.
Any hint will be very helpful. I am stuck..

below is my Java code

import matlabcontrol.MatlabConnectionException;
import matlabcontrol.MatlabInvocationException;
import matlabcontrol.MatlabProxy;
import matlabcontrol.MatlabProxyFactory;
import matlabcontrol.MatlabProxyFactoryOptions;

public class callSaliencymap {

* @param args
public static void main(String[] args) throws MatlabConnectionException, MatlabInvocationException
//Create a proxy, which we will use to control MATLAB
MatlabProxyFactory factory = new MatlabProxyFactory();
MatlabProxy proxy = factory.getProxy();

MatlabProxyFactoryOptions options = new MatlabProxyFactoryOptions.Builder()

factory = new MatlabProxyFactory(options);

//Create proxy factory

//test the saliencymap
Object[] saliencylocation = proxy.returningFeval("runActivation",1,"tank.bmp",1);

//Disconnect the proxy from MATLAB


This is what I did, hope it helps

MatlabProxyFactoryOptions options = new MatlabProxyFactoryOptions.Builder()

    MatlabProxyFactory factory = new MatlabProxyFactory(options);
    MatlabProxy proxy = factory.getProxy();