I am facing problem in running MATLAB code from Java. If you know something on this, could u please help me out?
You must have MATLAB Compiler SDK installed. Your Java environment must be properly configured. For details, see Configure Your Environment for Generating Java Packages. Your end users must have MATLAB or MATLAB Runtime installed to run compiled MATLAB code.
In general, use MATLAB syntax to call methods on Java objects. Alternatively, use Java syntax. javaMethod( StaticMethodName , ClassName , x1,...,xN ) calls the static method in class ClassName . In general, use MATLAB syntax to call static methods on Java objects.
The MATLAB® Engine API for Java® enables Java programs to interact with MATLAB synchronously or asynchronously, including: Start and terminate MATLAB. Connect to and disconnect from MATLAB sessions on the local machine.
There are two approaches for calling MATLAB code from Python. The first is to use the MATLAB Engine API for Python, which requires a MATLAB install. The second is to use MATLAB Compiler SDK to compile a Python package that does not require users to have a MATLAB install.
If you don't want to buy MathWork's MATLAB Builder for Java Toolbox, you can use MATLAB's undocumented JMI (Java-MATLAB Interface). Search the CSSM newsgroup (or Google) for JMI, or JMatLink which is based on JMI. The MATLAB code itself is full of JMI usage examples - search "jmi" using the MATLAB Editor's search tool over the entire MATLAB installation.
Note that JMI is neither documented nor officially supported by MathWorks. Moreover, if improperly used it can hang or crash your application. But it's free, unlike the toolbox.
Instead of using the undocumented JMI (Java MATLAB Interface) mentioned by Yair, you can use matlabcontrol which is a Java API that wraps around JMI which makes it much easier to use. It is well documented and has an introductory walkthrough. Unlike directly using JMI, it can also be used when running a Java program outside MATLAB.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With