Main Content

simscape.instrumentation.VariableTable

Store and manage block variable data

Since R2024a

Description

simscape.instrumentation.VariableTable returns an empty VariableTable object.

A VariableTable object represents the Simscape block variables in a key, value pair. key is a block variable of type string, and value is a simscape.instrumentation.VariableCongfiguration object associated with the variable. simscape.instrumentation.VariableTable returns an empty table that you can construct by inserting variables. You can apply the variable table to one or more of the same Simscape block. You can use object functions, or methods, with a VariableTable object.

keysk = keys(variableTable) returns an array of the block variable names for the VariableTable object, variableTable.
valuesvc = values(variableTable) returns an array of each VariableConfiguration object in the VariableTable object, variableTable.
inserttable = insert(variableTable,key,value) inserts the key, key, and the value, value, into the VariableTable object variableTable.
removetable = remove(variableTable,key) removes the key, key, from the VariableTable object , variableTable.

Creation

You create an empty VariableTable object when you set a workspace variable equal to simscape.instrumentation.VariableTable. You create a populated VariableTable object when you use either the simscape.instrumentation.defaultVariableTable or simscape.instrumentation.getVariableTable functions. You can return the names of block variables that are available for logging using the keys object function.

Examples

collapse all

  1. To create a variable table and save it as a workspace variable, enter:

    table1 = simscape.instrumentation.VariableTable
    table1 = 
    
      VariableTable with unset variable(s)

  2. Consider a Simscape block with the variable C.w. To configure the variable for logging, you must make a variable configuration to store the selective logging settings. To make a variable configuration for the variable C.w, enter:

    table1("C.w") = simscape.instrumentation.VariableConfiguration
    table = 
    
      VariableTable (string ⟼ VariableConfiguration) with 1 variable(s):
    
                    Name       Unit    Logging
                  _________    ____    _______
    
        C.w ⟼    <missing>     ""      false 

  3. You can also the insert object function to add a variable configuration.

    table1 = insert(table1, "R.w", simscape.instrumentation.VariableConfiguration)
    table1 = 
    
      VariableTable (string ⟼ VariableConfiguration) with 2 variable(s):
    
                    Name       Unit    Logging
                  _________    ____    _______
    
        C.w ⟼    <missing>     ""      false 
        R.w ⟼    <missing>     ""      false 
    

Version History

Introduced in R2024a