开发者

How to access a matlab function from java code?

My java program uses matlab code packaged as jar files for image processing. The problem is when I call a function(written by me) with a call to 'mmreader' for the first time, it works fine. However any subsequent call to a fu开发者_开发百科nction(same or different) calling 'mmreader' doesn't work and I get an error stating function mmreader not found.

I am also facing a similar problem in another part of my application where the call to matlab function simply throws an exception, the same piece of code works fine in other files.

try{
      vplayer.playmov(player_params);
   }
catch(Exception e){
            System.out.println("error playing cluster");
  }


I would take a quick look at this link Accessing Matlab from Java Here are a couple excerpts from the page that might be useful.

 mlapp.MLApp mlApp = new mlapp.MLApp(); 

 String result = mlApp.execute("a = [1 2 3 4; 5 6 7 8;]"); 
 System.out.println("Execute result is " + result); 

Inside those quotes, you can even call a MATLAB function, just make sure that you are assigning the output to the right data type.

The most important part of that link is;

We assume you have downloaded and expanded the J-Integra® kit from http://j-integra.intrinsyc.com/ and installed it correctly.

Without that installed, you cannot do the above statement.


Besides that, in MATLAB you can create a JAR with your functions and sign that JAR to only work with your applications. Perhaps you'll need the MATLAB runtime to make that app work I'm not sure about that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜