Main Content

getVariables

Return values of variables in data source workspace

Since R2022b

    Description

    example

    varValues = getVariables(dsWks,varNames) returns the values of the variables varNames that exist in the data source workspace represented by the Simulink.data.DataSourceWorkspace object dsWks.

    Examples

    collapse all

    Set the value of variables c and d in a data source workspace.

    setVariables(sourceWorkspace,["c" "d"], {3,4});

    Now return the variables.

    getVariables(sourceWorkspace,["c" "d"])
    
    ans =
    
    1x2 cell array
    
        {[3]}    {[4]}

    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'}

    Output Arguments

    collapse all

    Variable values, returned as a cell array of numbers, structures, or other MATLAB values. The dimensions of the cell array match the dimensions of varNames.

    Version History

    Introduced in R2022b