Using MATLAB with C and C++
Extend your MATLAB applications with existing C and C++ functions and
third-party libraries
Extend your MATLAB applications with existing C and C++ functions and
third-party libraries
In MATLAB®, you can extend your C and C++ code with a MEX function and call it like any MATLAB built-in function. That means you can use existing C and C++ code without rewriting your algorithms in MATLAB. MEX functions enable C and C++ code to create and modify MATLAB arrays in the MATLAB workspace. With C++ MEX functions, you can directly access MATLAB data using the standard C++ library with no unnecessary data copies.
In MATLAB, you can create an interface to third-party C and C++ libraries for scientific computation, hardware integration, or specialized file I/O. You can reduce development time using built-in tools to generate the interface without writing any C and C++ code. You can build the interface from header files or source code. Users of the library don't need a compiler to call library functions and use C++ objects in MATLAB.
Learn more
You can use MATLAB algorithms in your C and C++ applications. The MATLAB Engine API for C and C++ enables your applications to use and modify variables in the MATLAB workspace, call MATLAB functions, and evaluate MATLAB commands. Your C and C++ applications can also start and stop MATLAB instances or connect to an existing MATLAB instance.
If you need to deploy your MATLAB algorithms more broadly, use MATLAB Coder™ to generate ANSI C and C++ code from MATLAB code for a variety of platforms from desktop systems to embedded hardware.
Learn more