Data Logging
You can log simulation data to the workspace, or to a temporary file on disk, for debugging and verification. Data logging lets you analyze how internal block variables change with time during simulation. If you log simulation data, you can later query, plot, and analyze it without rerunning the simulation. You can use Simscape™ data logging and selective logging instrumentation to log block variable data.
Simscape data logging logs all variables for selected blocks or for all blocks in the model and outputs the data to the simulation log workspace variable. You can interactively visualize and navigate the Simscape data logging results with the Simscape Results Explorer tool. You can use data logging and the Simscape Results Explorer to view simulation results, instead of adding sensors and scopes to your model. To learn more, see Log, Navigate, and Plot Simulation Data.
Selective logging logs only the selected variables on the blocks with logging
enabled. Simscape logs the variables to a
Simulink.SimulationData.Dataset
object, along with Simulink® signals. You can enable selective logging for Simscape blocks with the
user interface. You can view and select block variables for logging in the
Instrumentation Table without compiling the model. To visualize the selective
logging results, use the Simulation Data Inspector. To learn more, see
Log Selected Block Variables.
You also manage selective logging instrumentation programmatically. To learn more, see Log Selected Variables Programmatically.
Tools
Simscape Results Explorer | Navigate and plot simulation data logging results |
Functions
Model Settings
Log simulation data | Option to specify whether to log Simscape simulation data to workspace |
Log simulation statistics | Option to specify whether to log simulation statistics as part of simulation data |
Record data in Simulation Data Inspector | Option to specify whether to stream Simscape data to Simulation Data Inspector |
Open viewer after simulation | Option to specify whether to open Simscape Results Explorer at the end of simulation run |
Workspace variable name | Name of workspace variable for Simscape simulation data logging |
Decimation | Option to reduce logged data points by skipping time steps |
Limit data points | Option to limit number of logged data points |
Data history (last N steps) | Number of data points to log |
Topics
Simscape Data Logging
- About Simscape Data Logging
You can log Simscape simulation data to the workspace, or to a temporary file on disk, for debugging and verification. - Enable Simscape Data Logging for the Whole Model
Using data logging for the whole model is a best practice. - Log Data for Selected Blocks Only
Instead of logging Simscape simulation data for the whole model, you can log data just for the selected blocks. - Data Logging Options
Additional options for logging and displaying the simulation data. - Stream Logging Data to Disk
When you log simulation data, you can stream the data to a temporary file on disk and have the workspace variable point to that temporary file. - Saving and Retrieving Logged Simulation Data
Methods of storing logged simulation data for future use and retrieving it at a later time. - Log, Navigate, and Plot Simulation Data
This example shows the basic workflow for logging simulation data for the whole model and then navigating and plotting the logged data using Simscape Results Explorer. - Log and Plot Simulation Data
This example shows how you can log and plot simulation data instead of adding sensors to your model. - Log Simulation Statistics
This example shows how you can access and analyze information on zero crossings during simulation. - Log and View Simulation Data for Selected Blocks
This example shows how you can set your model to log simulation data for selected blocks only and how to view simulation data using Simscape Results Explorer. - Plot Simulation Data in Different Units
When you display logged simulation data in Simscape Results Explorer, you can change they
-axis units directly on the plot. - Use Custom Units to Plot Simulation Data
This example shows how you can change to a custom unit display of logged simulation data. - Indexing into Component Arrays
You can use command-line interface to index into an array of components, for example, to get or set operating point targets for a particular array member, or to plot simulation data.
Selective Logging
- About Selective Logging
You can output data for selected Simscape block variables along with Simulink variables and signals. - Log Selected Block Variables
Log data for an individual block variable. - Log Selected Variables Programmatically
Programmatically configure selective logging.