Crate matfile

source ·
Expand description

Matfile is a library for reading (and in the future writing) Matlab “.mat” files.

Please note: This library is still alpha quality software and only implements a subset of the features supported by .mat files.

Feature Status

Matfile currently allows you to load numeric arrays from .mat files (all floating point and integer types, including complex numbers). All other types are currently ignored.

  • Loading .mat files
    • Numeric arrays
    • Cell arrays
    • Structure arrays
    • Object arrays
    • Character arrays
    • Sparse arrays
  • Writing .mat files

Examples

Loading a .mat file from disk and accessing one of its arrays by name:

let file = std::fs::File::open("tests/double.mat")?;
let mat_file = matfile::MatFile::parse(file)?;
let pos = mat_file.find_by_name("pos");
println!("{:#?}", pos);

Might output something like:

Some(
    Array {
        name: "pos",
        size: [
            2,
            3
        ],
        data: Double {
            real: [
                -5.0,
                8.0,
                6.0,
                9.0,
                7.0,
                10.0
            ],
            imag: None
        }
    }
)

Crate Feature Flags

The following crate feature flags can be enabled in your Cargo.toml:

  • ndarray
    • Enable conversions between Matfile and ndarray array types

Modules

  • Helpers for converting between matfile::Array and ndarray::Array.

Structs

  • A numeric array (the only type supported at the moment).
  • MatFile is a collection of named arrays.

Enums

  • Stores the data of a numerical array and abstracts over the actual data type used. Real and imaginary parts are stored in separate vectors with the imaginary part being optional.