Main Content

keys

Return block variable names for specified variable table object

Since R2024a

    Description

    k = keys(variableTable) returns the block variable names for the variable table object, variableTable.

    example

    Examples

    collapse all

    1. Create a variable table and save it as a workspace variable by entering:

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

    2. Suppose you have a Simscape block with the variable C.w. To configure the variable for logging, make a variable configuration to store the selective logging settings. Make a variable configuration for the variable C.w by entering:

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

    3. Use the insert 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 
      

    4. Return the block variables for table1.

      varNames = keys(table1)
      varNames = 
      
        2×1 string array
      
          "C.w"
          "R.w"

    Input Arguments

    collapse all

    Variable table, specified as a simscape.instrumentation.VariableTable object.

    Output Arguments

    collapse all

    Variable names for the elements in the variable table, returned as a string array.

    Version History

    Introduced in R2024a