Main Content

listVariables

List variables in data source workspace

Since R2022b

    Description

    varNames = listVariables(dsWks) lists the variables contained in 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 that list of variables and store the list in another variable vars.

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

    Input Arguments

    collapse all

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

    Output Arguments

    collapse all

    Variable names, returned as an array of strings or cell array of character vectors.

    Version History

    Introduced in R2022b