Main Content

clearAllVariables

Clear variables from data source workspace

Since R2022b

    Description

    clearAllVariables(dsWks) clears the variables from the data source workspace represented by the Simulink.data.DataSourceWorkspace object dsWks.

    example

    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});

    Now return the list of variables that are contained in the workspace.

    vars = listVariables(sourceWorkspace);
    vars
    vars
      5x1 string array
    
        "b"
    ...."c"
    ...."d"
        "e"
        "f"
    

    Clear the variables from the workspace.

    clearAllVariables(sourceWorkspace);

    Now return the list of variables again and confirm that the workspace is empty.

    vars = listVariables(sourceWorkspace);
    vars
    vars
      0x1 empty string array
    

    Input Arguments

    collapse all

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

    Version History

    Introduced in R2022b