Main Content

M-function

Description

Specify rule for naming identifiers in generated code.

Category: Code Generation > Identifiers

Settings

Default: ''

Enter the name of a MATLAB® language file that contains the naming rule to be applied to signal, parameter, or #define parameter identifiers in generated code. Examples of rules you might program in such a MATLAB function include:

  • Remove underscore characters from signal names.

  • Add an underscore before uppercase characters in parameter names.

  • Make identifiers uppercase in generated code.

For example, the following function returns an identifier name by appending the text _define to a data object name.

function revisedName = append_text(name, object)
% APPEND_TEXT: Returns an identifier for generated
% code by appending text to a #define data object name.
%
% Input arguments:
% name: data object name as spelled in model
% object: target data object
%
% Output arguments:
% revisedName: altered identifier returned for use in
% generated code.
%
%
text = '_define';

revisedName = [name,text];

Tip

The MATLAB language file must be in the MATLAB path.

Dependencies

This parameter:

  • Appears only for ERT-based targets.

  • Requires Embedded Coder® when generating code.

  • Is enabled by #define naming.

  • Must be the same for top-level and referenced models.

Command-Line Information

Parameter: DefineNamingFcn
Type: character vector
Value: MATLAB language file
Default: ''

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact

Related Topics