Main Content

Running MEX Functions

When you call a MEX function, pass it the same inputs that you use for the original MATLAB® algorithm. Do not pass coder.Constant or any of the coder.Type classes to a MEX function. You can use these classes with only the codegen function.

To run a MEX function generated by MATLAB Coder™, you must have licenses for all the toolboxes that the MEX function requires. For example, if you generate a MEX function from a MATLAB algorithm that uses a Computer Vision Toolbox™ function or System object™, to run the MEX function, you must have a Computer Vision Toolbox license.

When you upgrade MATLAB, before running MEX functions with the new version, rebuild the MEX functions.

Debugging MEX Functions

To debug your MEX functions, use the disp function to inspect the contents of your MEX function variables. You cannot use save to debug MEX function variables because code generation does not support it. Code generation does not support declaration of save as extrinsic.