read_mat

read_mat#

Read a variable from a MAT file into a tensor

Note

This function requires the optional MATX_ENABLE_FILEIO compile flag

MAT files can contain multiple named variables. Pass the variable name in var to select the tensor to read. MATLAB v7.3 MAT files are HDF5-based, but these helpers use SciPy’s MAT-file routines and are not a general HDF5 interface.

Added in version 0.3.0.

template<typename TensorType>
void matx::io::read_mat(TensorType &t, const std::string fname, const std::string var)#

Read a MAT file into a tensor view.

MAT files use SciPy’s loadmat() function to read MATLAB variables. MATLAB v7.3 MAT files are HDF5-based, but this helper is intended for MAT-file variables rather than as a general HDF5 interface.

Template Parameters:

TensorType – Data type of tensor

Parameters:
  • t – Tensor to read data into

  • fname – File name of .mat file

  • var – Variable name inside of .mat to read

template<typename TensorType>
auto matx::io::read_mat(const std::string fname, const std::string var)#

Read a MAT file and return a tensor view.

MAT files use SciPy’s loadmat() function to read MATLAB variables. MATLAB v7.3 MAT files are HDF5-based, but this helper is intended for MAT-file variables rather than as a general HDF5 interface.

Template Parameters:

TensorType – Data type of tensor

Parameters:
  • fname – File name of .mat file

  • var – Variable name inside of .mat to read

Returns:

Tensor view of data read from file

Examples#

// Read "myvar" from mat file
io::read_mat(t, "../test/00_io/test.mat", "myvar");