execute
R2026bSyntax
Description
collects results in the specified results = execute(metricEngine,metricIDs)metricEngine object for the metrics
identified by metricIDs.
collects metrics for a specific artifact in your project.results = execute(metricEngine,metricIDs,ScopeId=scopeId)
Examples
Use a metric.Engine object to collect design cost
metric data on a model reference hierarchy in a project.
To open the project, enter this command.
openExample('simulink/VisualizeModelReferenceHierarchiesExample')The project contains sldemo_mdlref_depgraph, which is the top-level
model in a model reference hierarchy. This model reference hierarchy represents one
design unit.
Create a metric.Engine object.
metric_engine = metric.Engine();
Update the trace information for metric_engine to reflect
any pending artifact changes.
updateArtifacts(metric_engine)
Create an array of metric identifiers for the metrics you want to collect. For this example, create a list of all available design cost estimation metrics.
metric_Ids = getAvailableMetricIds(metric_engine,... App="DesignCostEstimation")
metric_Ids =
1×2 string array
"DataSegmentEstimate" "OperatorCount"To collect results, execute the metric engine.
execute(metric_engine,metric_Ids);
Because you executed the engine without specifying a
ScopeId, the engine collects metrics for the entire
sldemo_mdlref_depgraph model reference hierarchy.
Use the generateReport function to access detailed metric
results in a PDF report. Name the report
"MetricResultsReport.pdf".
reportLocation = fullfile(pwd,"MetricResultsReport.pdf"); generateReport(metric_engine,... App="DesignCostEstimation",... Type="pdf",... Location=reportLocation);
The report contains a detailed breakdown of the operator count and data segment estimate metric results.

Input Arguments
Metric engine object for which to collect metric results, specified as a
metric.Engine object.
Metric identifiers for metrics to collect, specified as a character vector, cell array of character vectors, string, or string array. Collecting results for design cost metrics requires a Fixed-Point Designer™ license. For a list of design cost metrics and their identifiers, see Design Cost Model Metrics. For additional metrics, see Model and Code Testing Metrics (Simulink Check).
Example: "DataSegmentEstimate"
Example: ["DataSegmentEstimate", "OperatorCount"]
Digital thread URI for the artifact for which you want to collect metric results, specified as a string scalar.
A digital thread URI is a stable identifier for an artifact,
such as a model file, or a sub-file artifact, such as a block. The digital thread uses
these URIs as a consistent way to refer to artifacts across tools and inside metric
results. The scopes that a metric supports depend on the metric. To learn what scopes a
metric operates on, see the metric documentation. Use the appropriate function from the
digitalthread.uri namespace to get the URI for the artifact. For
example, use digitalthread.uri.simulink.fromObject to get the URI
for a model or element in a model.
Example: "mwdigitalthread://myProject/myModel.slx#addr=myModel/###"
Data Types: string
Output Arguments
Metric results, returned as an array of metric.Result
objects.
Version History
Introduced in R2022aIn R2026b, you can scope metric execution to a single artifact by using the
ScopeId argument. The ScopeId argument replaces
ArtifactScope, which is not recommended.
In releases prior to R2026b, you use the ArtifactScope argument by
specifying:
The full path to a project file, such as a model file.
The identifier of the object inside the project file, such as a block diagram name.
For example:
| Prior to R2026b | R2026b and later |
|---|---|
modelPath = fullfile(pwd,'myModel.slx'); execute(metricEngine,metricID,'ArtifactScope',{modelPath,'myModel'}); |
open_system("myModel"); storageMap = digitalthread.StorageMap.forProject(); modelURI = digitalthread.uri.simulink.fromObject(storageMap,get_param(gcs,"Handle")); results = execute(metricEngine,metricID,ScopeId=modelURI) |
Starting in R2026a, the execute function returns a
metric result object if there are any results. Previously, you needed to use the
getMetrics function to get metric results from the metric
engine.
See Also
metric.Engine | getAvailableMetricIds | generateReport | updateArtifacts | Design Cost Model Metrics | Model Testing Metrics (Simulink Check)
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.
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)