Main Content

clearVariables

Clear specified variables from data source workspace

Since R2022b

    Description

    example

    clearVariables(dsWks,varNames) clears the specified variables from the data source workspace represented by the Simulink.data.DataSourceWorkspace object dsWks.

    Examples

    collapse all

    Add some variables to a data source workspace.

    setVariable(sourceWorkspace,'b', 2);
    setVariables(sourceWorkspace,["c" "d"], {3,4});
    setVariables(sourceWorkspace,{'e','f'}, {5,6});

    Remove variables c and d from the workspace.

    clearVariables(sourceWorkspace,["c" "d"]);

    Now return the list of variables in the workspace and check that variables c and d are no longer there.

    vars = listVariables(sourceWorkspace);
    vars
    vars
      3x1 string array
    
        "b"
        "e"
        "f"
    

    Input Arguments

    collapse all

    Data source workspace, specified as a Simulink.data.DataSourceWorkspace object.

    Variable names, specified as a string array or cell array of character vectors.

    Example: ["c" "d"]

    Example: {'e', 'f'}

    Version History

    Introduced in R2022b