ILNumerics - Technical Application Development
SystemObject
ILNumericsMatFile
Assembly: ILNumerics.Core (in ILNumerics.Core.dll) Version: 5.5.0.0 (5.5.7503.3146)
Top
Top
Top
Top
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.
Matlab(R) .mat file class for reading from / writing to *.mat files.
[ILNumerics Core Module]
Inheritance Hierarchy
ILNumericsMatFile
Namespace: ILNumerics
Assembly: ILNumerics.Core (in ILNumerics.Core.dll) Version: 5.5.0.0 (5.5.7503.3146)
Syntax
The MatFile type exposes the following members.
Constructors
Name | Description | |
---|---|---|
MatFile |
Create an empty MatFile object. To be used to add arrays later on.
[ILNumerics Core Module] | |
MatFile(String) |
Create MatFile object from existing mat file
[ILNumerics Core Module] | |
MatFile(InCell) |
Create MatFile object from multiple arrays of arbitrary types. Automatically choose array names for saving.
[ILNumerics Core Module] |
Properties
Name | Description | |
---|---|---|
Arrays |
Retrieve a cell with all arrays stored in the mat file
[ILNumerics Core Module] | |
Count |
Number of arrays in the mat file container
[ILNumerics Core Module] | |
Filelocation |
Path to mat file, if this object was created from an existing mat file.
[ILNumerics Core Module] | |
Item |
Retrieves an array from this MatFile instance or replaces it.
[ILNumerics Core Module] | |
Keys |
List all key names currently stored with arrays
[ILNumerics Core Module] |
Methods
Name | Description | |
---|---|---|
AddArrayT |
Adds a new array to the collection of arrays in this MatFile container.
[ILNumerics Core Module] | |
Dispose |
Dispose all arrays of the matfile object
[ILNumerics Core Module] | |
GetArrayT(Int32) |
Retrieve array by index
[ILNumerics Core Module] | |
GetArrayT(String) |
Retrieves array by name.
[ILNumerics Core Module] | |
Write(Stream) |
Write this mat file into a binary stream
[ILNumerics Core Module] | |
Write(String) |
Write all arrays to *.mat file
[ILNumerics Core Module] |
Fields
Name | Description | |
---|---|---|
ReservedKeywords |
List of keywords which Matlab disallows for variable names
|
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