C++ with MATLAB - MATLAB & Simulink (original) (raw)
Main Content
Directly call C/C++ library functionality from MATLAB® or write modern C++ programs that call MATLAB functions
There are several ways to connect C/C++ and MATLAB:
- Shared libraries—If you have a C or C++ shared library that exports functionality, you can build and package a MATLAB interface to that library and share it with a MATLAB user. For details, see Call C++ from MATLAB.
- Access MATLAB from C++—To write C++ programs that launch MATLAB, evaluate MATLAB functions with arguments, and exchange data between MATLAB and C++ programs, use the MATLAB Engine API for C++. For details, see Call MATLAB from C++. To work with MATLAB data, see MATLAB Data API for C++.
- Run C++ code from MATLAB (MEX files)—To create MATLAB functions that provide the efficiency of C++ programs and that can access external functions and libraries from MATLAB, use the C++ MEX API. For details, see Write C++ Functions Callable from MATLAB (MEX Files).
Some existing code uses C interfaces that call the loadlibrary function or include the C Matrix API, but those interfaces have limited C++ language support. If you need to maintain such code, see Call C from MATLAB.
Categories
- Call C++ from MATLAB
Directly call C and C++ library functionality from MATLAB - Call C/C++ MEX Functions from MATLAB
A MEX file is a function, created in MATLAB, that calls a C/C++ program - Call MATLAB from C++
Run MATLAB code from C++ programs, with object-oriented programming support and asynchronous execution - MATLAB Data API for C++
Use the MATLAB Data API to read and write MATLAB data from C++ programs