File Exchange

image thumbnail

JMatIO - Matlab's MAT-file I/O in JAVA

version (203 KB) by Wojciech Gradkowski
Package contains Matlab's MAT-file I/O API in JAVA. Supports Matlab 5 MAT-flie format reading and wr


Updated 05 Oct 2007

View License

JMatIO is a JAVA library to read/write/manipulate with Matlab's binary MAT-files.

Currently supported data types are:
+ Double array
+ UInt8, Int8 array
+ UInt64, Int64 array
+ Char array
+ Structure
+ Cell array
+ Sparase array

this project is also available at

Cite As

Wojciech Gradkowski (2020). JMatIO - Matlab's MAT-file I/O in JAVA (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (16)

Thank you for your improvements Florian Enner.

Florian Enner

I ran into some fundamental issues when trying to save large data sets in a memory constrained environment, and I ended up writing my own library. I've made it available on in case anyone else has similar needs. It's already full featured and supports all data types.

Sanman Ganthe

Can support for UInt32 be added?

Ned Twigg

Great library, but it hasn't been updated in a while. I am maintaining a binary-compatible fork with some bugfixes and new features here:
- added support for 16-bit integers
- robust parsing of Java objects embedded in the MAT-File
- fixed some bugs in equals() and hashCode() implementations
- OSGI metadata
- available on Maven Central as com.diffplug.matsim:matfilerw


very useful! Thanks


How can we save a 3 dimensional array of type MLUInt8? I have the image stored in MWNumericArray format. I am able to create the array of 3 dimensions but I am not able to figure out how to copy the data inside it.

Lee Wei Yeong


how to use this library?

Stuart Bowman

Thank you! This is a big help in the world of java apps that produce data that engineers need to analyze. Great API.


very useful

Bryant Mairs

Would be useful to support the single data type. Odd omission from this library.


Execellent. But problem with large mat files. I have these error messages when reading a large mat file ( > 40 M):
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Unknown Source)
at Source)
at Source)
at Source)
at Source)
at<init>(Unknown Source)
at<init>(Unknown Source)
at com.Tester.common.Tester.main(

Is there a fix?

iskandar mamaik

Olav -

Very useful library

Leon Lee

Very useful!


+ Sparse matrix bugfixes
+ MatFileReader performance enhancements
+ new MatFileReader methods added

+ bugfix: struct/cell reading fails when containing empty arrays
+ added: int64 and uint64 support

+ REGRESSION BUG: double arrays created natively in Matlab are not read correctly (reversed byte ordering)

+ Added support:UInt8 array
+ MAJOR reading performance enhancement - reading is as fast as in Matlab now
+ Removed Log4j references

+improved performance of MatFileReader (~100% faster now)
+JUnit tests added to test and show usage of Cells and Strucutures

+bug fix: poor performance with big arrays
+documentation updated
+jmatio.jar added

+ bug fix: reading unsigned values
+ new constructor in MLDouble supporting double[][]
+ filtered reading of MAT-file
+ JUnit test updated

Following users' suggestions (thank you Imran) some code parts were modified:
+MLDouble array supports Jama style constructors, and JAVA types
+MLChar String exports
+MatFileReader maps content by name
+JUnit tests added
+JavaDoc added

MATLAB Release Compatibility
Created with R14SP2
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: CSMatIO: MAT-file I/O API for .NET 2.0