setFunction
Description
setFunction(
sets code mapping information for the specified model function. Use this function to set the
method name for a model function. For single-tasking periodic functions and Simulink® functions, you can use this function to set the argument specification,
including argument names, type qualifiers, and argument order. myCPPMappingObj
,function
,Name,Value
)
Examples
Set the Method Name for the Initialize Function for a Model
Open the model. To access the CodeMappingCPP
object associated with the model, use the coder.mapping.api.get
function.
open_system('CppClassRateBased'); cm = coder.mapping.api.get('CppClassRateBased');
To access the method name of the initialize function for the model, use the getFunction
function. If you did not specify a method name for the initialize function, the getFunction
function returns an empty character vector, and the method name in the generated code uses the default method name.
value = getFunction(cm, 'Initialize', 'MethodName')
value = 'initIntegrator'
Specify a method name for the initialize function by using the setFunction
function.
setFunction(cm, 'Initialize', 'MethodName', 'my_$N')
The getFunction
function now returns the specified method name.
value = getFunction(cm, 'Initialize', 'MethodName')
value = 'my_$N'
Input Arguments
myCPPMappingObj
— C++ code mapping object
CodeMappingCPP
object
C++ code mapping object, returned by a call to either the coder.mapping.utils.create
function or the coder.mapping.api.get
function.
function
— Model function
Initialize
| Terminate
| Periodic:slIdentifier
| Partition:slIdentifier
| Reset:slIdentifier
| ExportedFunction:slIdentifier
| SimulinkFunction:slIdentifier
Model function for which to set code mapping property value. Specify one of the values listed in this table.
Type of Model Function | Value |
---|---|
Exported function | ExportedFunction: ,
where is the name of
the function-call Inport block in the model |
Initialize function | Initialize |
Partition function | Partition: , where
is a partition
that was created explicitly from a block in the model and shown in the
Simulink Schedule Editor (for example, P1 ) |
Periodic multitasking function | Periodic: , where
is an annotation
that corresponds to the sample time period for a periodic or continuous rate of
a multi-tasking model (for example, D1 ) |
Periodic single-tasking function | Periodic |
Reset function | Reset: , where
is the name of
the reset function in the model |
Simulink function | SimulinkFunction: ,
where is the name of
the Simulink function in the model |
Terminate function | Terminate |
For information about model partitioning, see Create Partitions.
Example: 'Periodic:D1'
Name-Value Arguments
Example: 'MethodName', 'my_$N'
Specify comma-separated pairs of Name,Value
arguments.
Name
is the argument name and Value
is the
corresponding value. Name
must appear inside quotes. You can specify
several name and value pair arguments as Name1,Value1,…,NameN,ValueN
. The
order of the name and value pair arguments does not matter.
MethodName
— Name of method
character vector | string scalar
Name for the entry-point method in the generated C++ code, specified as a character vector or string scalar.
Data Types: char
| string
Arguments
— Argument specification
character vector | string scalar
Argument specification for the entry-point method in the
generated C++ code, specified as a character vector or string
scalar. The specification is a method prototype that shows
argument names, type qualifiers, and argument order, for example,
'y =(u1, const *u2)'
.
For an entry-point method that does not return a value, do not include an output argument in the prototype specification. For example,
setFunction(cm, 'SimulinkFunction:f','Arguments','(u, *y)');
When the model function specified is a periodic function, you can also customize parameter names in the argument specification.
setFunction(cm,'Periodic:D1','Arguments',... '(In1_1s & myParam1, In2_2s arg_In2_2s, * Out1 arg_Out1)');
Data Types: char
| string
Version History
Introduced in R2021a
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)