File Exchange

image thumbnail

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

version 1.0.0.0 (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

3 Downloads

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 http://sf.net/projects/jmatio

Comments and Ratings (15)

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 https://mathworks.com/matlabcentral/fileexchange/70357-mat-file-library in case anyone else has similar needs. It's already full featured and supports all data types.

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:

https://github.com/diffplug/matfilerw
- 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

Irma

very useful! Thanks

Jayant

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.

how to use this library?

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

rohit

very useful

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

Lei

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 java.io.ByteArrayOutputStream.write(Unknown Source)
at com.jmatio.io.MatFileReader.inflate(Unknown Source)
at com.jmatio.io.MatFileReader.readData(Unknown Source)
at com.jmatio.io.MatFileReader.read(Unknown Source)
at com.jmatio.io.MatFileReader.<init>(Unknown Source)
at com.jmatio.io.MatFileReader.<init>(Unknown Source)
at com.Tester.common.Tester.main(Tester.java:41)

Is there a fix?

iskandar mamaik

Olav -

Very useful library

Leon Lee

Very useful!

Updates

1.0.0.0

+ 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
Acknowledgements

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