Main Content

coder.MATLABCodeTemplate class

Package: coder

Represent code generation template for MATLAB Coder


Create a coder.MATLABCodeTemplate object from a code generation template (CGT) file. You can use this file to customize the code generation output for MATLAB® Coder™. If a CGT file is not provided, the coder.MATLABCodeTemplate object is created from the default template file matlabroot/toolbox/coder/matlabcoder/templates/matlabcoder_default_template.cgt.


newObj = coder.MATLABCodeTemplate() creates a coder.MATLABCodeTemplate object from the default code generation template (CGT) file matlabroot/toolbox/coder/matlabcoder/templates/matlabcoder_default_template.cgt.

newObj = coder.MATLABCodeTemplate(CGTFile) creates a coder.MATLABCodeTemplate object from the code generation template file CGTFile. If the file is not on the MATLAB path, specify a full path to the file.

Input Arguments


Name of code generation template file


emitSectionEmit comments for template section
getCurrentTokensGet current tokens
getTokenValueGet value of token
setTokenValueSet value of token for code generation template

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects.


newObj = coder.MATLABCodeTemplate()
newObj = 

  MATLABCodeTemplate with properties:

    CGTFile: 'matlabcoder_default_template.cgt'
newObj = coder.MATLABCodeTemplate('custom_matlabcoder_template.cgt')
newObj = 

  MATLABCodeTemplate with properties:

    CGTFile: 'custom_matlabcoder_template.cgt'