Read Matlab variables from .m file to C++

3 views (last 30 days)
Juri Romazanov
Juri Romazanov on 30 Sep 2015
Suppose I have a Matlab text file 'data.m' with the contents
% matlab 2x2 matrix
A=[1,2;3,4]
I would like to read the matrix A into a variable of my C++ code, something like
vector<int> v;
matlab_read<int> ("data.m", "A", &v);
I only need to parse Matlab variables, not Matlab functions.
Is there some C++ parser library or API which can do this?
(I know there is there are Matlab APIs like engine.h or mat.h, but I would rather prefer some open source library, so that people without Matlab can also run the code.)

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!