Search Results for

    Show / Hide Table of Contents

    Class MatlabReader

    Reads the contents of a MAT file.

    Inheritance
    Object
    MatlabReader
    Implements
    IDisposable
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: Microsoft.ML.Probabilistic.Serialization
    Assembly: Microsoft.ML.Probabilistic.dll
    Syntax
    public class MatlabReader : IDisposable
    Remarks

    The MAT file format is defined in The MAT file format.

    Constructors

    MatlabReader(Stream)

    Create a MatlabReader that reads from the given stream.

    Declaration
    protected MatlabReader(Stream reader)
    Parameters
    Type Name Description
    Stream reader

    The stream to read from

    MatlabReader(String)

    Create a MatlabReader that reads from the given file name.

    Declaration
    protected MatlabReader(string fileName)
    Parameters
    Type Name Description
    String fileName

    The MAT file name to read from

    Methods

    Dispose()

    Release the stream used by this MatlabReader

    Declaration
    public void Dispose()

    GetType(mxClass)

    Declaration
    protected Type GetType(mxClass dataClass)
    Parameters
    Type Name Description
    mxClass dataClass
    Returns
    Type Description
    Type

    Matlab5DataElement(out String)

    Read the next data element from the stream

    Declaration
    protected object Matlab5DataElement(out string name)
    Parameters
    Type Name Description
    String name

    On exit, the variable name

    Returns
    Type Description
    Object

    The data value, as a .NET object

    Matlab5Header()

    Read a MAT file header from the stream

    Declaration
    protected string Matlab5Header()
    Returns
    Type Description
    String

    The header as a string

    Parse(MatType, out String)

    Read a specific data type from the stream

    Declaration
    protected object Parse(MatType dataType, out string name)
    Parameters
    Type Name Description
    MatType dataType

    The type number as documented by the MAT format

    String name

    On exit, the variable name

    Returns
    Type Description
    Object

    The data value, as a .NET object

    ParseString(Byte[], Int32, Int32)

    Convert an array of bytes into a string

    Declaration
    protected static string ParseString(byte[] bytes, int start, int length)
    Parameters
    Type Name Description
    Byte[] bytes

    The bytes

    Int32 start

    The position of the first character in the string

    Int32 length

    An upper bound on the length of the string

    Returns
    Type Description
    String

    Read(String)

    Read all variables from a file and store them in a dictionary

    Declaration
    public static Dictionary<string, object> Read(string fileName)
    Parameters
    Type Name Description
    String fileName

    The name of a MAT file

    Returns
    Type Description
    Dictionary<String, Object>

    A dictionary that maps variable names into values

    ReadAll()

    Read all variables from the current stream and store them in a dictionary

    Declaration
    protected Dictionary<string, object> ReadAll()
    Returns
    Type Description
    Dictionary<String, Object>

    A dictionary that maps variable names into values

    ReadArray(mxClass, Int32[])

    Declaration
    protected Array ReadArray(mxClass dataClass, int[] sizes)
    Parameters
    Type Name Description
    mxClass dataClass
    Int32[] sizes
    Returns
    Type Description
    Array

    ReadBoolArray(Int32)

    Declaration
    protected object ReadBoolArray(int count)
    Parameters
    Type Name Description
    Int32 count
    Returns
    Type Description
    Object

    ReadCellArray(Int32[])

    Declaration
    protected Array ReadCellArray(int[] sizes)
    Parameters
    Type Name Description
    Int32[] sizes
    Returns
    Type Description
    Array

    ReadCsv(String)

    Read a csv file (with a header row) as a set of columns

    Declaration
    public static Dictionary<string, List<string>> ReadCsv(string path)
    Parameters
    Type Name Description
    String path
    Returns
    Type Description
    Dictionary<String, List<String>>

    A mapping from column name to a list of column values

    Remarks

    Also see Microsoft.VisualBasic.FileIO.TextFieldParser

    ReadDouble()

    Read a double-precision float from the stream

    Declaration
    protected double ReadDouble()
    Returns
    Type Description
    Double

    ReadElement(MatType)

    Declaration
    protected object ReadElement(MatType elementClass)
    Parameters
    Type Name Description
    MatType elementClass
    Returns
    Type Description
    Object

    ReadInt()

    Read a 32-bit integer from the stream

    Declaration
    protected int ReadInt()
    Returns
    Type Description
    Int32

    ReadInt16()

    Read a 16-bit integer from the stream

    Declaration
    protected short ReadInt16()
    Returns
    Type Description
    Int16

    ReadInt64()

    Read a 64-bit integer from the stream

    Declaration
    protected long ReadInt64()
    Returns
    Type Description
    Int64

    ReadIntArray(Int32)

    Declaration
    protected object ReadIntArray(int count)
    Parameters
    Type Name Description
    Int32 count
    Returns
    Type Description
    Object

    ReadLongArray(Int32)

    Declaration
    protected object ReadLongArray(int count)
    Parameters
    Type Name Description
    Int32 count
    Returns
    Type Description
    Object

    ReadMatrix(mxClass, Int32, Int32)

    Declaration
    protected Matrix ReadMatrix(mxClass dataClass, int rows, int cols)
    Parameters
    Type Name Description
    mxClass dataClass
    Int32 rows
    Int32 cols
    Returns
    Type Description
    Matrix

    ReadMatrix(Double[,], String)

    Declaration
    public static double[, ] ReadMatrix(double[, ] matrix, string filename)
    Parameters
    Type Name Description
    Double[,] matrix
    String filename
    Returns
    Type Description
    Double[,]

    ReadMatrix(Double[,], String, Char)

    Declaration
    public static double[, ] ReadMatrix(double[, ] matrix, string filename, char separator)
    Parameters
    Type Name Description
    Double[,] matrix
    String filename
    Char separator
    Returns
    Type Description
    Double[,]

    ReadPadding(Int32, Boolean)

    Declaration
    protected void ReadPadding(int numBytesRead, bool isSmallFormat)
    Parameters
    Type Name Description
    Int32 numBytesRead
    Boolean isSmallFormat

    ReadSingle()

    Read a single-precision float from the stream

    Declaration
    protected float ReadSingle()
    Returns
    Type Description
    Single

    ReadString()

    Declaration
    protected string ReadString()
    Returns
    Type Description
    String

    ReadString(Int32)

    Read a string of known length from the stream

    Declaration
    protected string ReadString(int length)
    Parameters
    Type Name Description
    Int32 length

    The number of bytes in the string

    Returns
    Type Description
    String

    ReadStruct()

    Declaration
    protected Dictionary<string, object> ReadStruct()
    Returns
    Type Description
    Dictionary<String, Object>

    ReadTypeAndSize(out MatType, out Int32)

    Declaration
    protected bool ReadTypeAndSize(out MatType type, out int numBytes)
    Parameters
    Type Name Description
    MatType type
    Int32 numBytes
    Returns
    Type Description
    Boolean

    ReadUInt()

    Read an unsigned 32-bit integer from the stream

    Declaration
    protected uint ReadUInt()
    Returns
    Type Description
    UInt32

    ReadUInt16()

    Read an unsigned 16-bit integer from the stream

    Declaration
    protected ushort ReadUInt16()
    Returns
    Type Description
    UInt16

    ReadUInt64()

    Read an unsigned 64-bit integer from the stream

    Declaration
    protected ulong ReadUInt64()
    Returns
    Type Description
    UInt64

    ReadUIntArray(Int32)

    Declaration
    protected object ReadUIntArray(int count)
    Parameters
    Type Name Description
    Int32 count
    Returns
    Type Description
    Object

    ReadULongArray(Int32)

    Declaration
    protected object ReadULongArray(int count)
    Parameters
    Type Name Description
    Int32 count
    Returns
    Type Description
    Object

    RemoveRfc1950Header(Byte[])

    Removes the header defined by RFC 1950

    Declaration
    protected static byte[] RemoveRfc1950Header(byte[] bytes)
    Parameters
    Type Name Description
    Byte[] bytes
    Returns
    Type Description
    Byte[]

    A smaller array of bytes

    Remarks

    The header to remove is 2 or 6 bytes at the start, and 4 bytes at the end.

    SizeOf(MatType)

    Get the size in bytes of a MatType

    Declaration
    public static int SizeOf(MatType type)
    Parameters
    Type Name Description
    MatType type
    Returns
    Type Description
    Int32

    Number of bytes

    Implements

    System.IDisposable
    In This Article
    Back to top Copyright © .NET Foundation. All rights reserved.