How to write and use mex files for Matlab
Howto use predefined mexfiles
A range of mexfiles is predefined in directorylibrary/mex
. Many of these mexfile process ui files (see User Infos and their use) examples of these files are in directory library/tutorial
. Note that in order to run these files you need to let matlab know where to find them: >> addpath path_to_bdm/library/mex
Then, you can go to library/tutorial
and run e.g. arx_test_mex
.
Howto write custom mex file
Due to special nature of the mex files, the mex file can be split in three parts:- input conversion, where input arguments are converted to IT++ structures,
- main body of algorithm, where any C++ bdm constructions can be used,
- output conversion, where resulting IT++ structures are converted to mxArrays.
Script ./buildmex is prepared to compile and link the mexfile with bdm.
$ ./buildmex.sh my_mex_file.cpp
$ ./buildmex.bat my_mex_file.cpp
Example of a mexfile:
Generated on 2 Dec 2013 for mixpp by 1.4.7