Main Content

getVariable

Return value of variable in data source workspace

Since R2022b

    Description

    example

    varValue = getVariable(dsWks,varName) returns the value of the variable varName that exists in the data source workspace represented by the Simulink.data.DataSourceWorkspace object dsWks.

    Examples

    collapse all

    Set the value of variable b in a data source workspace.

    setVariable(sourceWorkspace,'b',2);

    Now return that variable and store the value in another variable c.

    c = getVariable(sourceWorkspace,'b');
    c
    ans =
    
        2

    Input Arguments

    collapse all

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

    Variable name, specified as a string or character array.

    Example: "x"

    Data Types: char | string

    Output Arguments

    collapse all

    Variable value, returned as a number, structure, or other MATLAB value.

    Version History

    Introduced in R2022b