Main Content

Log Selected Block Variables

You can use selective logging to configure your Simscape blocks to only log the variables you choose. When you use selective logging and run the model, Simscape logs the data to logsout, the default Simulink.SimulationData.Dataset object workspace variable. When you select a block, you can view the variables for that block in the Simscape Variables tab of the Model Data Editor. Once Simscape logs the instrumented variables, you can view the logged data in the Simulation Data Inspector.

Open the Permanent Magnet DC Motor example by using:

openExample('simscape/PermanentMagnetDCMotorExample')

Permanent Magnet DC Motor example model.

Use Selective Logging to Log an Individual Block Variable

To use selective logging to log a block variable, open the Instrumentation table in the Simscape Variables tab of the Model Data Editor. To open the Instrumentation table, select the block and in the Simscape Block tab, select Log Variables > Instrumentation Table.

Ideal Torque Source block variables highlighted and selected.

The Instrumentation table in the Simscape Variables tab displays all the variables available for logging at the current canvas level.

Model Data Editor window with the Simscape Variables tab open. The variables for the Load Torque block are visible.

Select the Log Data check boxes for the variables that you want to log. For example, select the check box for the t variables of the Load Torque source.

You can provide an alias to track variables across variant subsystems by using the Name column. For example, double-click the Name cell for the t variable and set the name to Torque. You can also change the which units the selected variable uses in the log data. For example, double-click the Unit cell for the t variable, and set the unit to ft*lbf.

Model Data Editor window shows t variable with alias 'Torque', units of 'ft*lbf', and logging enabled.

Note

By default, the Model Data Editor window shows only the variables that belong to your current canvas level. To display variables that belong to model subsystems, click the Change scope button Change scope button icon..

You can also include the Simulink signal data for the Motor RPM block in Simulink Data Inspector by enabling Simulink data logging for the signal.

Log Selected Signal button selected from the toolstrip of the Simulink signal going to the Motor RPM block.

View the Results

To view the results, run the model and open the Simulation Data Inspector. You can open the tool by clicking the logging badge on the block icon or by opening the Simulation tab and clicking Data Inspector.

Ideal Torque Source block with logging badge.

Selective logging data appears in the Simscape Instrumentation section. To see the results, select a variable. If you assign the variable a custom name, the name appears in the left pane. Expand Properties pane to view the units and other details. When you log Simulink data in the same model, the data appears in the Signals section.

The checkbox next to the 'Torque' variable is selected.

Note

You can display the block path by clicking the Settings Simulation Data Inspector Properties button icon. button, and in the Inspect settings, select Data Type. You may need to group the data by domain to separate selective logging data from Simscape data logging data and Simulink data. To learn more, see Configure the Simulation Data Inspector.

See Also

| |