Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 function(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");
  }
like image 967
meraj Avatar asked Nov 14 '22 01:11

meraj


1 Answers

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.

like image 180
Kyle Uithoven Avatar answered Dec 16 '22 21:12

Kyle Uithoven