Skip to content Skip to sidebar Skip to footer

Not a Binary Mat-file. Try Load -ascii to Read as Text.

Accord.NET (logo)

MatReader Class

Reader for .mat files (such as the ones created by Matlab and Octave).

Inheritance Bureaucracy

SystemObject
Accordance.IOMatReader

Namespace: Accordance.IO
Assembly: Accord.Math (in Accordance.Math.dll) Version: 3.eight.0

Syntax

The MatReader type exposes the following members.

Constructors

Properties

Name Description
Public property BaseStream

Returns the underlying stream.

Public property BigEndian

Gets whether the MAT file uses the Big-Endian standard for bit-order. Currently, simply little endian is supported.

Public property Code example Description

Gets the human readable description of the MAT file.

Public property FieldNames

Gets the name of the variables contained in this file. Those tin exist used every bit keys to the Fields property to retrieve a variable or navigate the variable hierarchy.

Public property Fields

Gets the child nodes contained in this file.

Public property ItemInt32

Gets a child object contained in this node.

Public property ItemString

Gets a kid object contained in this node.

Public property Transpose

Gets whether matrices will be auto-transposed to .NET row and column format if necessary.

Public property Version

Gets the version data about the file. This field should always contain 256.

Elevation

Methods

Name Description
Public method Dispose

Performs application-divers tasks associated with freeing, releasing, or resetting unmanaged resource.

Protected method Dispose(Boolean)

Releases unmanaged and - optionally - managed resource

Public method Equals

Determines whether the specified object is equal to the electric current object.

(Inherited from Object.)
Protected method Finalize

Releases unmanaged resources and performs other cleanup operations before the MatReader is reclaimed past garbage collection.

(Overrides ObjectFinalize .)
Public method GetHashCode

Serves as the default hash role.

(Inherited from Object.)
Public method GetType

Gets the Type of the current example.

(Inherited from Object.)
Protected method MemberwiseClone

Creates a shallow copy of the current Object.

(Inherited from Object.)
Public method Read(Cord)

Reads an object from a given key.

Public method ReadT(String)

Reads an object from a given key.

Public method ToString

Returns a string that represents the electric current object.

(Inherited from Object.)

Pinnacle

Extension Methods

Name Description
Public Extension Method HasMethod

Checks whether an object implements a method with the given name.

(Defined by ExtensionMethods.)
Public Extension Method IsEqual

Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.

(Divers past Matrix.)
Public Extension Method To(Blazon) Overloaded.

Converts an object into some other blazon, irrespective of whether the conversion can be done at compile time or not. This tin can exist used to convert generic types to numeric types during runtime.

(Defined by ExtensionMethods.)
Public Extension Method ToT Overloaded.

Converts an object into another blazon, irrespective of whether the conversion tin can be done at compile time or non. This tin can be used to convert generic types to numeric types during runtime.

(Divers by ExtensionMethods.)

Pinnacle

Remarks

MAT files are binary files containing variables and structures from mathematical processing programs, such as MATLAB or Octave. In MATLAB, .mat files can be created using its save and load functions. For the moment, this reader supports only version 5 MAT files (Matlab five MAT-file).

The MATLAB file format is documented at http://www.mathworks.com/help/pdf_doc/matlab/matfile_format.pdf

Examples

All the examples below involve loading files from the following URL: https://github.com/accord-net/framework/blob/development/Unit%20Tests/Accord.Tests.Math/Resource/mat/

The first example shows how to read a unproblematic .MAT file containing a unmarried matrix of integer numbers. It also shows how to discover the names of the variables stored in the file and how to notice their types:

                                 string              pathInt32 = Path.Combine(localPath,              "int32.mat");                var              reader =              new              MatReader(pathInt32);                string[] names = reader.FieldNames;                    object              unknown = reader.Read("a");   Type t = unknown.GetType();                  int[,] matrix = reader.Read<int[,]>("a");            

The 2d example shows how to read a uncomplicated .MAT file containing a single matrix of 8-bpp integer values (signed bytes):

                                 string              pathInt8 = Path.Combine(localPath,              "int8.mat");                var              reader =              new              MatReader(pathInt8);                sbyte[,] matrix = reader.Read<sbyte[,]>("arr");                   string[] names = reader.FieldNames;            

The 3rd example shows how to read a more complex .MAT file containing a structure. Structures can hold complex types such as collections of matrices, lists, and strings in a nested hierarchy:

                                 string              fileName = Path.Combine(localPath,              "simplestruct.mat");                var              reader =              new              MatReader(fileName);                string              description = reader.Description;               int              version = reader.Version;                   bool              bigEndian = reader.BigEndian;                   foreach              (var              field              in              reader.Fields)     Console.WriteLine(field.Central);                 var              construction = reader["structure"];                foreach              (var              field              in              structure.Fields)     Panel.WriteLine(field.Key);                 var              aType = structure["a"].ValueType;                 var              a = construction["a"].GetValue<byte[,]>();                var              southward = reader["structure"]["string"].GetValue<string>();

The MatReader class can also read the more circuitous cell array structures. However, in that location is no example of this functionality right at present, except for those unit tests currently in the project repository. If you lot would like examples for this characteristic, delight open a new upshot at the project'due south issue tracker.

Come across Also

Reference

jackmanunshes1939.blogspot.com

Source: http://accord-framework.net/docs/html/T_Accord_IO_MatReader.htm

Postar um comentário for "Not a Binary Mat-file. Try Load -ascii to Read as Text."