Be the first to rate this file! 8 Downloads (last 30 days) File Size: 2.57 KB File ID: #27350

C++ class to write HDF5 .mat files.

by Tim

 

23 Apr 2010

This is a small C++ class that lets you write matrices, vectors and values to a .mat file.

| Watch this File

File Information
Description

This is a small C++ class that lets you write matrices, vectors and values to a .mat file. It is simple enough that you can easily modify it yourself.

The mat file format is simply an HDF5 file with a pointless header prepended. This class uses libhdf5 from here:

http://www.hdfgroup.org/HDF5/release/obtain5.html

to write the HDF5 file, and the prepends the header to it. Currently it reads the entire file back in and writes it all out again with the header, because I couldn't get the HDF5 library to append to an existing file. If anyone knows how I'd love to know!

The resulting files can be loaded in matlab using

load('/path/to/file.mat'); % Puts contents in main workspace.
s = load('/path/to/file.mat'); % Puts contents in s structure.

MATLAB release MATLAB 7.10 (R2010a)
Other requirements libhdf5 from http://www.hdfgroup.org/HDF5/release/obtain5.html
Tags for This File  
Everyone's Tags
c, cplusplus, data, export, format, hdf5, mat, save, write
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
20 Jun 2012 Marcus

Nice work!

Is it possible to make it write out nd-matrixes? I would need at least a 3d.

22 May 2012 Tim

It definitely linked fine when I wrote it! Can you post the errors you get, and how you are building it?

21 May 2012 Ki

Hello there, this is a good idea to write a wrapper to read/write mat with hdf5. But I found that it fail to link the hdf5 library in linux, so many undefined references found

Contact us