I'm calling MATLAB program from Eclipse Java interface. I have used MatlabControl for it. When I run Java program multiple time, every time it opens a new instance of MATLAB, and that makes the computation slower.
Is it possible that I can prevent it from opening new instances of MATLAB? If possible, how can I do this?
If I have an already opened terminal of MATLAB, is it possible that the computation can simply use that terminal, instead of opening a new instance of MATLAB?
Any help would be appreciable.
The matlabcontrol can not connect to an already open instance of matlab, it can only create a new one.
To prevent multiple matlab instances being opened, you can use proxy.exit()
instead of proxy.disconnect()
to close matlab when closing your application.
To further use only a single instance of matlab across multiple instances of your java program, I see different possibilities but no very good one.
Here is a comment from matlabcontrol tutorial regarding this problem:
Comment by khai...@gmail.com, Feb 9, 2012 To reuse the existing session, the previous proxy needs to be disconnected first. Here is an example,
MatlabProxyFactoryOptions options = new MatlabProxyFactoryOptions.Builder().setUsePreviouslyControlledSession(true).build();
MatlabProxyFactory factory = new MatlabProxyFactory(options);
MatlabProxy proxy = factory.getProxy();
...
proxy.disconnect();
proxy = factory.getProxy(); // this won't open a new Matlab session
It did not work for me. But some ppl claim it did the job.
Thanks. Is there any other way apart from matlabcontrol that can fulfill my requirement? – user24094
Other alternatives to matlabcontrol here: https://code.google.com/p/matlabcontrol/wiki/ApproachesToControl
Hope you manage, its a real pain ITA to work like that.... cheers
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.