matio-cpp
v0.2.5
A C++ wrapper of the matio library, with memory ownership handling, to read and write .mat files.
|
matio-cpp
is a C++ wrapper for the matio
library, automatically dealing with memory allocation and deallocation. It can be used for reading and writing binary MATLAB .mat
files from C++, without the need to access or rely on MATLAB's own shared libraries.
The depencies are CMake
(minimum version 3.10) and matio
. While we suggest to follow the build instructions provided in the matio
home page, it can also installed from common package managers:
sudo apt install libmatio-dev
conda-forge
: mamba install -c conda-forge libmatio
Eigen
is an optional dependency. If available, some conversions are defined.
For running the tests, it is necessary to install Catch2
. Where supported, valgrind
can be installed to check for memory leaks.
Notice: sudo
is not necessary if you specify the CMAKE_INSTALL_PREFIX
. In this case it is necessary to add in the .bashrc
or .bash_profile
the following lines:
With IDE build tool facilities, such as Visual Studio:
In order to allow CMake finding matio-cpp
, it is necessary that the installation folder is in the PATH
.
matio-cpp
provides native CMake support which allows the library to be easily used in CMake projects
In order to use matio-cpp
in your project, add the following in your CMakeLists.txt
matio-cpp
can handle the following data types:
double
, int
, ...Structs
All these types can be read/written from/to .mat
files.
Read a .mat
file
Write a .mat
file
It is possibile to convert common types to matioCpp
types with the function matioCpp::make_variable
. Examples:
If eigen
is available, it is also possible to convert from and to eigen
types:
matioCpp
also exploits visit_struct
to parse C++ structs into matioCpp
structs. Example:
You can check the example in the example
folder on how to include and use matioCpp
.
.mat
file (this is a matio
limitation https://github.com/tbeu/matio/issues/99).mat
file (this is a matio
limitation https://github.com/tbeu/matio/issues/98)Struct
from a .mat
file (this is a matio
limitation related to https://github.com/tbeu/matio/issues/98)