coder.ExternalDependency
is an abstract class
for encapsulating the interface between external code and MATLAB® code
intended for code generation. You define classes that derive from coder.ExternalDependency
to
encapsulate the interface to external libraries, object files, and
C/C++ source code. This encapsulation allows you to separate the details
of the interface from your MATLAB code. The derived class contains
information about external file locations, build information, and
the programming interface to external functions.
To define a class, myclass
, make the following
line the first line of your class definition file:
classdef myclass < coder.ExternalDependency
You must define all of the methods
listed in Methods. These methods
are static and are not compiled. When you write these methods, use coder.BuildConfig
methods
to access build information.
You also define methods that call the external code. These methods
are compiled. For each external function that you want to call, write
a method to define the programming interface to the function. In the
method, use coder.ceval
to call the external
function. Suppose you define the following method for a class named AdderAPI
:
function c = adder(a, b) coder.cinclude('adder.h'); c = 0; c = coder.ceval('adder', a, b); end
adder
which
has two inputs a
and b
.
In your MATLAB code, call adder
this way:y = AdderAPI.adder(x1, x2);
getDescriptiveName | Return descriptive name for external dependency |
isSupportedContext | Determine if build context supports external dependency |
updateBuildInfo | Update build information |