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.

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.

Object Functions

keysReturn block variable names for specified variable table object
valuesReturn configuration for specified variable table object
insertInsert key and value into variable table object
removeRemove key from variable table object

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