2

I trained my model in MATLAB and the model parameters are saved in .mat file. I want to read all the parameters in C++.

I have uploaded a similar model here.

I can open the model.mat file using matOpen and access the field names. But I'm not able to access the contents of array of structures.

Can someone help me with that.

Thank you.

Illuminati0x5B
  • 602
  • 7
  • 24
  • probably not a Matlab issue since you're only using it's format – krisdestruction Apr 23 '15 at 01:34
  • The [MATLAB MAT File Spec](http://www.mathworks.com/help/pdf_doc/matlab/matfile_format.pdf) might be of help but i feel like somebody must have created a library for this..... – Rollen Apr 23 '15 at 01:39
  • One link that popped up quite fast after a google search on read mat files in c++ this [mat file API from matlab](http://se.mathworks.com/help/matlab/read-and-write-matlab-mat-files-in-c-c-and-fortran.html). That one includes links to examples as well. – patrik Apr 23 '15 at 06:26

1 Answers1

2

You could take a look into matio: www.github.com/tbeu/matio

Matio is an open-source C library for reading and writing MATLAB MAT files. This library is designed for use by programs/libraries that do not have access or do not want to rely on MATLAB's shared libraries.

It supports all MATLAB file versions, including (nested) structs and cells.

Nils
  • 2,665
  • 15
  • 30