CMake/MatlabMex

From KitwarePublic
Jump to navigationJump to search

What are Matlab mex files?

Mex files are functions written in C or C++ that are callable in the Matlab scripting language in a Matlab interpretor. Matlab is a 'Matrix Laboratory', a general purpose scientific scripting language owned by The Mathworks company.

Details of writing mex files can be found in the Matlab documentation.

Before you begin

Matlab is a language with a good syntax for working with matrices, a variety of functions, excellent documentation, and it is ubiquitous throughout the academic, scientific community. On the other hand, it is extremely slow, has poor memory utilization, is prohibitively expensive, sees little use outside academia, has a language syntax that is only good for simple procedural scripting, is closed source, and has numerous bugs. Writing mex files is often an attempt to address some of these limitations -- speed and memory usage. However, it is a difficult and not very elegant solution. Instead, researchers should consider using superior products, such as SciPy, SciLab, Sage, or Octave.

Why would you want to use CMake for creating mex files?

How do you use CMake with Matlab?

Hello World Example

More complex example: ITK based image reader

Platform specific issues