ILNumerics Ultimate VS

MatFileWrite Method (String)

ILNumerics Ultimate VS Documentation
ILNumerics - Technical Application Development
Write all arrays to *.mat file

[ILNumerics Core Module]

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

public void Write(
	string filename


Type: SystemString
Filename of the file to write the mat file to

The method writes the full content of the matfile to the file specified. If the filename points to a file which already exists, that file will be overwritten. Otherwise a new file will be created.

The file will be suitable for reading by ILNumerics.MatFile classes or by compatible *.mat file readers - including e.g. matlab

[ILNumerics Core Module]


// 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");

// 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