addMethod
R2026bAdd method specification to coder.ClassSignature object (Tech
Preview)
Since R2026a
Syntax
Description
Note
Using a MATLAB® class as an entry point for code generation is a tech preview. This
feature is in active development and might change between the tech preview and the
general release. To enable the feature, enter
enableCodegenForEntryPointClasses at the command line before
launching the MATLAB
Coder™ app, calling the codegen function, or creating a coder.Type object. To provide feedback, email the
development team or participate
in a survey.
When you specify a MATLAB class as an entry point for code generation, use the
addMethod function to add methods to the coder.ClassSignature
object. At a minimum, you must add the class constructor method. If the MATLAB class does not define a constructor, add the default constructor.
addMethod(
adds the method classSig,methodName,args)methodName with the arguments args
to the coder.ClassSignature object classSig.
addMethod(
specifies options for classSig,methodName,args,Name=Value)methodName by using one or more name-value
arguments. For example, to set the number of output arguments to two, set
Nargout to 2.
addMethod(
adds the method specified by the classSig,fsObj)coder.FunctionSignature object fsObj to the coder.ClassSignature object
classSig.
Examples
Input Arguments
Name-Value Arguments
Limitations
Tips
The class constructor method must define all properties of the class, including all structure fields, cell array elements, and properties of contained classes.
If the entry-point class is a System object™, you must add the System object
stepmethod to the class signature object. Becausestepsupports a variable number of outputs, you must specify the number of output arguments when you add the method. For an example, see Generate C++ Executable for Entry-Point System Object in a Namespace.
Version History
Introduced in R2026a
See Also
codegen | coder.ClassSignature | coder.FunctionSignature | coder.Type