MATLAB: How to read MAT files from Java

exportfilesjavajnimatMATLAB

I have a large Java application that needs to read the results of numerical processing in MATLAB. Currently I am saving my MATLAB data in MAT files. I need to import this data into Java.

Best Answer

In order to read MAT files into Java, you have the following options:
1)MathWorks offers a full enterprise product called MATLAB Builder JA, for direct communication between MATLAB and Java. Using the MATLAB Builder JA product, you can wrap MATLAB-code functions from the MATLAB product into one or more Java classes.
For further details regarding this product, refer to the following link:
The MATLAB Builder JA product is an extension to the MATLAB Compiler product. It requires the MATLAB Compiler product. Please refer the following link for further details:
2)You could write your own functionality that would call the native MATLAB LIBMAT library. You may need to use the Java Native Interfaces (JNI) API to run C/C++ or FORTRAN code that could directly use the LIBMAT functions.
You can read about the JNI API at the following websites:
For further information regarding the LIBMAT library, refer to the following documentation link:
3) Alternatively, you can save your MATLAB data using a different data format. For example, MATLAB can write data to an ASCII data file or an HDF5 file. For very large data files, you could also use compression and other means to optimize performance in terms of speed and disk usage.