Writing MATLAB C/MEX Code

MEX: Combine the power of MATLAB and C


Updated 1 Apr 2010

View License

Learn how to create MEX-functions: programs written in C, C++, or Fortran code that are callable from MATLAB. This article is a guide to getting started and performing practical tasks as well as a reference.

* Introduction
* Getting Started
* Inputs and Outputs
* Creating an Uninitialized Numeric Array
* Calling a MATLAB function from MEX
* Calling a MATLAB function handle from MEX
* Calling MATLAB from a non-MEX program
* Memory
* Non-Numeric Variables
* FFTs with FFTW
* Miscellaneous
* Further Reading

Cite As

Pascal Getreuer (2023). Writing MATLAB C/MEX Code (https://www.mathworks.com/matlabcentral/fileexchange/27151-writing-matlab-c-mex-code), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Software Development Tools in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes