setFunction
Set code mapping information for model function
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,funcID,Name,Value)
Examples
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
C++ code mapping object, returned by a call to either the coder.mapping.utils.create function or the coder.mapping.api.get function.
The identifier of the model method to set the code mappings property value for, specified as one of the values in the table.
| Type of Model Method | Method Identifier |
|---|---|
| Initialize method |
|
| Terminate method |
|
| Reset method |
|
| Periodic method |
Example: Tip For a single-tasking periodic method, you can use
|
| Periodic update method |
Example: Tip For a single-tasking periodic update method, you can use
|
| Partition method |
Example: |
| Partition update method |
Example: |
| Simulink function |
|
| Exported method |
|
Tip
When the configuration parameter Single output/update function is cleared, you can specify the update method that corresponds to a partition, periodic multitasking, or periodic single-tasking method. For more information about generating code with a single method for both update and output, see Single output/update function.
For information about model partitioning, see Create Partitions. To learn more about annotations and sample time information, see Specify Sample Time. To learn how to programmatically obtain sample time information, see simulink.schedule.OrderedSchedule.
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.
Name for the entry-point method in the generated C++ code, specified as a character vector or string scalar.
Data Types: char | string
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
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)