Main Content

setClassName

Set class name of model

Description

example

setClassName(myCPPMappingObj, name) sets the class name of the model in the generated code.

Examples

collapse all

Open the model. To access the CodeMappingCPP object associated with the model, use the coder.mapping.api.get function.

open_system('rtwdemo_cppclass');
cm = coder.mapping.api.get('rtwdemo_cppclass');

To access the class name of the model, use the getClassName function. If you did not specify a class name for the model, the getClassName function returns an empty character vector, and the class name in the generated code uses the default class name.

name = getClassName(cm)
name =

    'ModelClass'

Specify a class name for the model by using the setClassName function.

setClassName(cm, 'myClassName');

The getClassName function now returns the specified class name.

name = getClassName(cm)
name =

    'myClassName'

Input Arguments

collapse all

C++ code mapping object, returned by a call to either the coder.mapping.utils.create function or the coder.mapping.api.get function.

Class name of model in the generated code, specified as a character vector. If you do not specify a class name, the class name of the model in the generated code is set to the name of the model.

Data Types: char | string

Introduced in R2021a