ILNumerics Ultimate VS

MatFileAddArrayT Method

ILNumerics Ultimate VS Documentation
ILNumerics - Technical Application Development
Adds a new array to the collection of arrays in this MatFile container.

[ILNumerics Core Module]

Namespace:  ILNumerics
Assembly:  ILNumerics.Core (in ILNumerics.Core.dll) Version: 5.4.0.0 (5.4.7431.3055)
Syntax

public string AddArray<T>(
	BaseArray<T> A,
	string key
)

Parameters

A
Type: ILNumericsBaseArrayT
Array to be added.
key
Type: SystemString
The name to be used as key for identifying A among the arrays in this MatFile.

Type Parameters

T

Return Value

Type: String
String used to identify the array in the collection of arrays.
Exceptions

ExceptionCondition
ArgumentExceptionIf the new name key or the element type of A do not fullfill the restrictions defined by Matlab.
Remarks

[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