metric.Result
Results from specified metric
Description
A metric.Result object contains the results for a specified
metric.
Creation
Description
creates a
handle to a metric result object.metric_result = metric.Result
Alternatively, if you collect results by executing a metric.Engine
object, using the getMetrics function on the engine object returns the
collected metric.Result objects in an array.
Properties
User data provided by the metric algorithm, returned as a string.
Value of the metric result for the specified metric and artifacts, returned as an integer, string, double vector, or structure. For a list of model testing metrics and their result values, see Model Testing Metrics.
Metric identifier for the metric that calculated the results, returned as a string.
Example:
'TestCasesPerRequirementDistribution'
Project artifacts for which the metric is calculated, returned as a structure or an array of structures. For each artifact that the metric analyzed, the returned structure contains these fields:
UUID— Unique identifier of the artifact.Name— Name of the artifact.ParentUUID— Unique identifier of the file that contains the artifact.ParentName— Name of the file that contains the artifact.
Data Types: struct
Scope of the metric results, returned as a structure. The scope is the unit or component for which the metric collected results. The structure contains these fields:
UUID— Unique identifier of the unit or component.Name— Name of the unit or component.ParentUUID— Unique identifier of the file that contains the unit or component.ParentName— Name of the file that contains the unit or component.
Data Types: struct
Since R2025a
Errors and warnings from the metric collection, returned as a structure or an array of structures. Each structure contains these fields:
Severity— Severity of the diagnostic message, returned as either"ERROR"or"WARNING".Identifier— Identifier for the diagnostic message.Message— Diagnostic message.
Data Types: struct
Examples
Use a metric.Engine object to collect metric results
on the design artifacts in a project.
Open a project containing models that you want to analyze. For this example, in the MATLAB® Command Window, enter:
openExample("slcheck/ExploreTestingMetricDataInModelTestingDashboardExample"); openProject("cc_CruiseControl");
Create a metric.Engine object. You can use the
metric.Engine object to collect the metric results for the current
project.
metric_engine = metric.Engine();
Collect results for the metric slcomp.OverallCyclomaticComplexity by
executing the metric engine. For more information on the metric, see Model Maintainability Metrics.
execute(metric_engine,'slcomp.OverallCyclomaticComplexity');Use the function getMetrics to access the results. Assign the array of result objects to the results variable.
results = getMetrics(metric_engine,'slcomp.OverallCyclomaticComplexity');Access the metric results data by using the properties of the metric.Result objects in the results array.
for n = 1:length(results) disp(['Model: ',results(n).Scope.Name]) disp([' Overall Design Cyclomatic Complexity: ',num2str(results(n).Value)]) end
Model: cc_DriverSwRequest Overall Design Cyclomatic Complexity: 9 Model: cc_ThrottleController Overall Design Cyclomatic Complexity: 4 Model: cc_ControlMode Overall Design Cyclomatic Complexity: 22 Model: cc_CruiseControl Overall Design Cyclomatic Complexity: 1 Model: cc_LightControl Overall Design Cyclomatic Complexity: 4
For more information on how to collect metrics for design artifacts, see Collect Model Maintainability Metrics Programmatically.
Collect metric results on the requirements-based testing artifacts in a
project. Then, access the data by using the metric.Result
objects.
Open a project that contains models and testing artifacts. For this example, in the MATLAB Command Window, enter:
openExample("slcheck/ExploreTestingMetricDataInModelTestingDashboardExample"); openProject("cc_CruiseControl");
Create a metric.Engine object. You can use the
metric.Engine object to collect metric results for the current
project.
metric_engine = metric.Engine();
Update the trace information for metric_engine to ensure that the artifact information is up to date.
updateArtifacts(metric_engine)
Collect results for the metric 'RequirementsPerTestCase' by using the execute function on the metric.Engine object.
execute(metric_engine,'RequirementsPerTestCase');Use the function getMetrics to access the results. Assign the array of result objects to the results variable.
results = getMetrics(metric_engine,'RequirementsPerTestCase');Access the metric results data by using the properties of the metric.Result objects in the array.
for n = 1:length(results) disp(['Test Case: ',results(n).Artifacts(1).Name]) disp([' Number of Requirements: ',num2str(results(n).Value)]) end
Version History
Introduced in R2020bYou can return diagnostic errors and warnings that occur during metric collection by
using the Diagnostics property
metric.Result objects do not return the fields Type
and ParentType for the properties Artifacts and
Scope.
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.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- 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)