ILNumerics Ultimate VS

MatFile Class

ILNumerics Ultimate VS Documentation
ILNumerics - Technical Application Development
Matlab(R) .mat file class for reading from / writing to *.mat files.

[ILNumerics Core Module]

Inheritance Hierarchy

SystemObject
  ILNumericsMatFile

Namespace:  ILNumerics
Assembly:  ILNumerics.Core (in ILNumerics.Core.dll) Version: 5.5.0.0 (5.5.7503.3146)
Syntax

public sealed class MatFile : IDisposable

The MatFile type exposes the following members.

Constructors

  NameDescription
Public methodMatFile
Create an empty MatFile object. To be used to add arrays later on.

[ILNumerics Core Module]

Public methodCode exampleMatFile(String)
Create MatFile object from existing mat file

[ILNumerics Core Module]

Public methodCode exampleMatFile(InCell)
Create MatFile object from multiple arrays of arbitrary types. Automatically choose array names for saving.

[ILNumerics Core Module]

Top
Properties

  NameDescription
Public propertyCode exampleArrays
Retrieve a cell with all arrays stored in the mat file

[ILNumerics Core Module]

Public propertyCount
Number of arrays in the mat file container

[ILNumerics Core Module]

Public propertyCode exampleFilelocation
Path to mat file, if this object was created from an existing mat file.

[ILNumerics Core Module]

Public propertyItem
Retrieves an array from this MatFile instance or replaces it.

[ILNumerics Core Module]

Public propertyKeys
List all key names currently stored with arrays

[ILNumerics Core Module]

Top
Methods

  NameDescription
Public methodCode exampleAddArrayT
Adds a new array to the collection of arrays in this MatFile container.

[ILNumerics Core Module]

Public methodDispose
Dispose all arrays of the matfile object

[ILNumerics Core Module]

Public methodCode exampleGetArrayT(Int32)
Retrieve array by index

[ILNumerics Core Module]

Public methodCode exampleGetArrayT(String)
Retrieves array by name.

[ILNumerics Core Module]

Public methodWrite(Stream)
Write this mat file into a binary stream

[ILNumerics Core Module]

Public methodCode exampleWrite(String)
Write all arrays to *.mat file

[ILNumerics Core Module]

Top
Fields

  NameDescription
Public fieldStatic memberReservedKeywords
List of keywords which Matlab disallows for variable names
Top
Remarks

This class reads and writes Matlab .mat files version 6. All numeric array types are supported. The reading and writing of Matlab cell arrays is not supported.

[ILNumerics Core Module]

Examples

// MatFile should be used in an 'using' block, 
// cleaning up its resources automatically.
using (MatFile mat = new MatFile()) {
    mat.AddArray(counter<sbyte>(-10, 2, 4, 8, 13), "myArray");
    mat.Write("file.mat");
}

// reading back using ILMath.loadArray<T>(...)
Array<sbyte> A = loadArray<sbyte>("file.mat", "myArray");
Assert.IsTrue(A.Equals(counter<sbyte>(-10, 2, 4, 8, 13)));

// reading back using MatFile
using (var back = new MatFile("file.mat")) {
    Array<sbyte> B = back.GetArray<sbyte>("myArray");

    // ... or usign cell methods: 
    Array<sbyte> C = back.Arrays.GetArray<sbyte>(0);

    Assert.IsTrue(B.Equals(counter<sbyte>(-10, 2, 4, 8, 13)));
    Assert.IsTrue(C.Equals(counter<sbyte>(-10, 2, 4, 8, 13)));
}
See Also

Reference