C with MATLAB
calllib or write C programs that call
                        MATLAB functions using mxArray to access or create
                    MATLAB variables in CMATLAB provides multiple interfaces to C and C++ language programs. Whenever possible, choose the C++ interfaces over the C-only versions. For more information, see C++ with MATLAB.
- If you need to maintain existing code that calls C shared library functionality using the - calllibfunction, then see Call C from MATLAB. For using C libraries with MATLAB R2022a or later, see Call C++ from MATLAB.
- To launch MATLAB from C programs, evaluate MATLAB functions with arguments, and exchange data between MATLAB and C programs, use the MATLAB engine API for C. For more information, see Call MATLAB from C. 
- 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 more information, see Write C Functions Callable from MATLAB (MEX Files). 
- If you must write a custom program to interact with MATLAB data — for example, you want to read data from an external application, but you do not have access to the source code — then see Write C Programs to Read MAT File Data. 
If you write C programs, you can use this code to work with MATLAB data using the C Matrix API. This interface has limited C++ language support.
Categories
- Call C from MATLAB
 Directly call C library functions from MATLAB R2021b or earlier, usingcalllibfunction
 
- Write C Functions Callable from MATLAB (MEX Files)
 Create C functions that can be called from MATLAB R2017b or earlier, usingmxArrayto access MATLAB variables and create arrays to return to MATLAB
 
- Call MATLAB from C
 Run MATLAB code from C programs, usingmxArray
 
- Write C Programs to Read MAT File Data
 Read and write MATLAB data from C programs, usingmxArray
 
- C Matrix API
 Use the C Matrix API to create C programs that use themxArraytype to represent MATLAB data