4

I'm writing an application which does image processing using matlab and later displays the result using Java's Interface. Due to certain reasons I've to use both Java and Matlab.

How can I use the matlab function in java ?? How to create and access the interface.

Amro
  • 123,847
  • 25
  • 243
  • 454
Mahesh Gupta
  • 2,688
  • 9
  • 30
  • 46

4 Answers4

4

matlabcontrol is a Java API which will allow you to call your image processing functions or scripts and return the results to Java. To get started, take a look at the walkthrough.

Joshua Kaplan
  • 843
  • 5
  • 9
  • Have you migrated matlabcontrol from google code to github or similar? I would hate to create yet another "unofficial" clone in github. It would be great to have an upstream repo for better collaboration and enhancements. – pakman Oct 07 '15 at 14:15
2

MATLAB Builder JA is one option to use MATLAB code in Java. This is a non free toolbox for creating a jar file from MATLAB code in order to be imported to Java. Take care of the restrictions concerning jar file creation.

Using Java classes inside MATLAB is much easier, as you can instantiate Java classes in MATLAB code. Undocumented Matlab is one valuable resource for Java integration in MATLAB.

Check Using Sun Java Classes in MATLAB Software for the official information provided by The MathWorks.

zellus
  • 9,617
  • 5
  • 39
  • 56
  • will it be possible for me to write a java code such that I can create a full fledged java application with very good look & feel + connectivity with Database kind of thing using Matlab's Java support ?? – Mahesh Gupta Feb 15 '11 at 15:48
  • @Mew 3.4: You won't be able to integrate MATLAB figures within your Java application. For a good look & feel you have to choose a Java plotting library. For the non gui parts write the MATLAB code as 'simple' functions and compile them. Going the other, you have to decide whether the MATLAB gui is suitable for your needs. Database connectivity, java image processing libraries can easily be accessed from within MATLAB. – zellus Feb 15 '11 at 18:25
1

A quick google brought up this http://j-integra.intrinsyc.com/support/com/doc/other_examples/Matlab.htm

Alternatively, can you execute your matlab function from the command line? If so you can use Runtime.getRuntime().exec("your matlab function")

Tarski
  • 5,360
  • 4
  • 38
  • 47
  • I was talking about executing my own code which I've written in Matlab. Runtime.getRuntime() function will make it very much slower.. – Mahesh Gupta Feb 15 '11 at 15:47
0

As of R2016b you can use official MATLAB Engine API for Java, which seems to allow same functionality as matlabcontrol.

nirvana-msu
  • 3,877
  • 2
  • 19
  • 28