Main Content

C++ withMATLAB

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, seeCall 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, seeCall MATLAB from C++. To work with MATLAB data, seeMATLAB Data API for C++.

  • 从MATLAB c++代码运行(墨西哥人文件)——创建垫LAB 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, seeWrite C++ Functions Callable from MATLAB (MEX Files).

Some existing code uses C interfaces that call theloadlibraryfunction or include theC Matrix API, but those interfaces have limited C++ language support. If you need to maintain such code, seeCall C from MATLAB.

Categories