setFunction
Description
setFunction(
sets code mapping information for the specified model function. Use this function to set the
function customization template, memory section, or function 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. myCodeMappingObj
,function
,Name,Value
)
Examples
Configure Function Name for Model Initialize Function
In the model code mappings for model
myConfigModel
, configure the name of the generated C initialize
function as myInitFunction
.
cm = coder.mapping.api.get('myConfigModel'); setFunction(cm,'Initialize','FunctionName','myInitFunction');
Configure Memory Section for Periodic Single-Tasking Function
In the model code mappings for model
myInitFunction
, configure the memory section for the periodic
single-tasking function as None
.
cm = coder.mapping.api.get('myInitFunction'); setFunction(cm,'Periodic','MemorySection','None');
Configure Function Customization Template for Periodic Multitasking Function for Sample Time D2
In the model code mappings for model
myInitFunction
, configure the function customization template for the
periodic multitasking function for sample time D2 as FastFcn
.
cm = coder.mapping.api.get('myInitFunction'); setFunction(cm,'Periodic:D2','FunctionCustomizationTemplate','FastFcn');
Configure Argument Specification for Simulink Function
In the model code mappings for model
myInitFunction
, configure the argument specification for Simulink function mySLFunc
as y=(u1, const
*u2)
.
cm = coder.mapping.api.get('myInitFunction'); setFunction(cm,'mySLFunc','Arguments','y=(u1, const *u2)');
Input Arguments
myCodeMappingObj
— Code mapping object
CodeMapping
object
Code mapping object (model code mappings) returned by a call to function
coder.mapping.api.get
.
Example: myCM
function
— Model function
Initialize
| Terminate
| Periodic:slIdentifier
| Partition:slIdentifier
| PeriodicUpdate:slIdentifier
| PartitionUpdate:slIdentifier
| Reset:slIdentifier
| ExportedFunction:slIdentifier
| SimulinkFunction:slIdentifier
Model function for which to return a code mapping property value. Specify one of the values listed in this table. If model configuration parameter Single output/update function is cleared, you can specify the update version of a partition, periodic multi-tasking, or periodic singletasking function.
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 ), or a task
name in the Concurrent Execution dialog |
Partition update function | PartitionUpdate: ,
is a partition that was created explicitly from a block in the model and shown
in the Simulink Schedule Editor (for example, P1 ), or a task
name in the Concurrent Execution dialog |
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 multitasking update function | PeriodicUpdate: ,
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 |
Periodic single-tasking update function | PeriodicUpdate |
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: 'FunctionCustomizationTemplate' 'exFastFunction'
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.
FunctionCustomizationTemplate
— Name of function customization template
character vector | string scalar
Name of a function customization template defined in the Embedded Coder Dictionary
associated with the model, specified as a character vector or string scalar. If you
set the default function customization template for a category of functions to
Default
, you can specify a memory section for the functions
category.
Data Types: char
| string
MemorySection
— Name of memory section
character vector | string scalar
Name of a memory section that is defined in the Embedded Coder Dictionary associated with the model, specified as a character vector or string scalar.
Data Types: char
| string
FunctionName
— Name of function
character vector | string scalar
Name for the entry-point function 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 function in the generated C code,
specified as a character vector or string scalar. The specification is a function
prototype that shows argument names, type qualifiers, and argument order (for example,
y=(u1, const *u2)
.
Data Types: char
| string
Version History
Introduced in R2020b
See Also
coder.mapping.api.CodeMapping
| coder.mapping.api.get
| getFunction
| getFunctionDefault
| setFunctionDefault
Topics
- Configure Names for Individual C Entry-Point Functions (Embedded Coder)
- Configure Name and Arguments for Individual Step Functions (Embedded Coder)
- Configure Default C Code Generation for Categories of Data Elements and Functions (Embedded Coder)
- C Code Generation Configuration for Model Interface Elements (Embedded Coder)
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes 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)