Hauptinhalt

deleteMetrics

R2026b

Delete specific metric results

Since R2022a

    Description

    deleteMetrics(metricEngine,metricIDs) deletes the metric results specified by metricIDs for the specified metricEngine object. To delete all metric results, use deleteAllMetrics.

    example

    deleteMetrics(___,Name=Value) specifies options using one or more name-value arguments in addition to any of the input argument combinations in the previous syntaxes. For example, specify deleteMetrics(metricEngine,"slcomp.ComponentStructure",ScopeId=modelURI) to delete metric results for a specific model, specified by a digital thread URI.

    example

    Examples

    collapse all

    To delete metric results for a specific metric, use the deleteMetrics function.

    Open a project. For this example, in the MATLAB® Command Window, enter:

    openExample("slcheck/ExploreTestingMetricDataInModelTestingDashboardExample");
    openProject("cc_CruiseControl");

    Create a metric.Engine object to collect metric results.

    metricEngine = metric.Engine();
    

    To collect component structure and design traceability metrics, execute the metric engine with the relevant metric IDs.

    res = execute(metricEngine,["slcomp.ComponentStructure","modeldesign.TraceabilityAnalysis[slcomp.Links]"])
    res = 
    
      1×9 Result array with properties:
    
        UserData
        Value
        MetricID
        Artifacts
        ScopeId
        ScopeAlias
        ThresholdOutcomes
        Diagnostics

    Delete the metric results for the design traceability metric.

    deleteMetrics(metricEngine,"modeldesign.TraceabilityAnalysis[slcomp.Links]")

    Get the metric results again. The returned result array contains fewer results because you deleted the design traceability metric results.

    res = getMetrics(metricEngine,["slcomp.ComponentStructure","modeldesign.TraceabilityAnalysis[slcomp.Links]"])
    res = 
    
      1×5 Result array with properties:
    
        UserData
        Value
        MetricID
        Artifacts
        ScopeId
        ScopeAlias
        ThresholdOutcomes
        Diagnostics

    To delete metric results for a specific artifact, specify a digital thread URI.

    If you inspect the metric results, you can see that there are metric results for five models.

    res.ScopeAlias

    In this example, delete metric results for the model cc_DriverSwRequest.

    Get the digital thread URI for the model.

    myModel = "cc_DriverSwRequest";
    storageMap = digitalthread.StorageMap.forProject();
    load_system(myModel);
    modelURI = digitalthread.uri.simulink.fromObject(storageMap,get_param(myModel,"Handle"));

    Delete metric results only for the specified model.

    deleteMetrics(metricEngine,"slcomp.ComponentStructure",ScopeId=modelURI)

    Get the metric results again. The returned result array contains fewer results because you deleted the metric results for the cc_DriverSwRequest model.

    res = getMetrics(metricEngine,["slcomp.ComponentStructure","modeldesign.TraceabilityAnalysis[slcomp.Links]"]);
    res.ScopeAlias

    Input Arguments

    collapse all

    Metric engine, specified as a metric.Engine object.

    Metric identifiers for the metric results that you want to delete, specified as a string array or string scalar. Use the getAvailableMetricIds function to return a list of available metric identifiers.

    Data Types: string

    Name-Value Arguments

    collapse all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: deleteMetrics(metricEngine,"slcomp.ComponentStructure",ScopeId=modelURI)

    Digital thread URI for the artifact whose metric results you want to delete, 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. To get the digital thread URI for a specific artifact, use the functions in the digitalthread.uri namespace, such as digitalthread.uri.simulink.fromObject. If you do not specify ScopeId, the function deletes metric results for all artifacts in the project.

    Note

    You cannot use ScopeId to delete table metrics. Table metrics are the metrics that use the bracket notation, such as "modeldesign.TraceabilityAnalysis[slcomp.Links]". You can delete table metrics only for all artifacts. To delete results for a table metric, use the syntax without ScopeId. For example, deleteMetrics(metricEngine,"modeldesign.TraceabilityAnalysis[slcomp.Links]")

    Data Types: string

    Include imported metric results, specified as a numeric or logical 1 (true) or 0 (false).

    When you specify a table metric ID, setting this value to true also deletes the results of any base metrics that that table metric configuration imports. When this value is false, the function deletes only the table metric's own results.

    Use this option to help make sure that imported metric data is recalculated when you rerun the table metric.

    Data Types: logical

    Version History

    Introduced in R2022a