JAVA calls Matlab code (MATLAB 2014a)

I consider that using java to draw graphics and implement some calculations is not efficient, and it is a bit complicated to implement. It is more convenient to use MATLAB to write the corresponding calculation function, and then package it into a jar package for Java to call. Or sometimes it involves using Java to call MatLab to display some two-dimensional and three-dimensional images. So use Java to call MatLab source code.
The MATLAB 2014a version used in this article
First , we need to install JDK1.7/1.8, because the java corresponding to the Matlab2014a version is 1.7, otherwise the generated jar package will be incompatible and cannot be used.
write picture description here
Next, I will explain in detail how to make a matlab function into a jar package
1) Create a new script, write the function into it, and then enter deploytool on the command line, the following window will pop up, select Libary Compiler
write picture description here
2) Select the type of package, and fill in the function and class name In the
write picture description here
above picture 1. Select java Package;
2. Select the script we wrote in advance;
3. If the jar is running on the computer where matlab is installed, put the first tick, if it is installed on the computer without matlab, select the second line tick.
4. Class name
5. Method name
3) After all selections are completed, click the green tick Package in the upper right corner, and the following interface will appear
write picture description here
4) Generate jar package
write picture description here
5) Call, in addition, you need to put the jar package in the following figure into the project. In this way, we can write java code to call functions written in matlab.
write picture description here
write picture description here

The relevant code is in my Baidu cloud, you can download it. Link: http://pan.baidu.com/s/1i5h6XId Password: 9wpl

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325707948&siteId=291194637