find - Get model elements for the category of model code mappings - MATLAB (original) (raw)
Main Content
Get model elements for the category of model code mappings
Since R2021a
Syntax
Description
[modelElementsFound](#mw%5Fe0d0999f-8710-4684-81bf-670176ade235) = find([myCPPMappingObj](#mw%5F0c2b61c9-7166-4af6-a766-5f89bd85fd1b),[category](#mw%5F561982cc-6437-4292-aafc-b8ae9fe4fa6b))
returns the elements in the model code mappings of the specified category as an array of objects.
[modelElementsFound](#mw%5Fe0d0999f-8710-4684-81bf-670176ade235) = find([myCPPMappingObj](#mw%5F0c2b61c9-7166-4af6-a766-5f89bd85fd1b),[category](#mw%5F561982cc-6437-4292-aafc-b8ae9fe4fa6b),'MethodName', [methodName](#mw%5F8a57e234-bd7e-4b51-9752-3f16a655fdc5))
returns the model functions in the model code mappings with the specified method name.
Examples
You can use the find
function to find all model elements of a specific category in the code mappings.
Open the model. To access the CodeMappingCPP
object associated with the model, use the coder.mapping.api.get
function.
open_system('CppClassWorkflowKeyIgnition'); cm = coder.mapping.api.get('CppClassWorkflowKeyIgnition');
Find all functions with an unset method name by using the find
function.
unsetMethods = find(cm, 'Functions', 'MethodName', '')
unsetMethods = 1×4 string "Initialize" "Terminate" "Periodic:D1" "Periodic:D2"
To specify a method name for the functions, use the setFunction
function.
setFunction(cm, unsetMethods, 'MethodName', 'my_$N')
Input Arguments
Category of model elements to search for in the model code mappings.
Example: 'ResetFunctions'
Name of an entry-point function generated for a model.
Example: 'my_$N'
Data Types: char
| string
Output Arguments
Model elements found, returned as an array or string vector of functions. Each object identifies a model element of the specified category. If you specify additional search criteria, the array or string vector includes objects for model elements of the specified category that meet the additional search criteria.
Version History
Introduced in R2021a