ILNumerics - Technical Computing

Modern High Performance Tools for Technical

Computing and Visualization in Industry and Science

 

mat-files

ILNumerics.ILMatFile5 is able to create *.mat files version 6, which are compatible to any common *.mat file format reader/ writer, including Matlab®. Newer versions of Matlab store data in HDF5 format. Go to the HDF5 interface section in order to learn how to handle that in ILNumerics.

Every instance of ILMatFile corresponds to a *.mat file on disk. The class serves as a container for any number of named arrays, capable of storing the arrays on disk and reloading them into ILNumerics arrays.

Load array "A" from mat file "sample.mat":

A shortcut exists:

Write arrays A and B into a mat file version 6:

The ILMatFile allows convenient access to the items of the file of your favourite IDE:

ILMat File Debugger ILNumerics

The arrays to be stored are added to ILMatFile instances by using the indexer (C#) with a name as a key. Array names must be unique in the mat file. If an empty string was used as a name, the Name property of the array is used as the key instead or a unique name is generated automatically. In languages, which do not support indexer, the AddArray() function can be used. If an array with the same key already exists in the mat file, it will be replaced.

In order to retrieve an array from a mat file on disk, the path of the file is given to the ILMatFile constructor. Arrays are fetched from the ILMatFile instance, by using of the GetArray<T>() function. In order to identify the array to return, the key or the index of the array inside the mat file is expected. Also, the element type must explicitly be given to GetArray<T>(). See lines 15..17 in the example above.

ILMatFile implements the IDisposable interface. Instances of the class should be used in a 'using(){' block (C#) or disposed manually after use.

Further Readings: Data I/O and the HDF5 API

Visit the class reference for the ILMatFile class in order to learn more about the options when dealing with mat files.

The mat file format supported by ILNumerics has been deprecated by Matlab. Newer mat files are stored in HDF5 format and are supported by ILNumerics by means of its HDF5 API.