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. For example, you might want to see that the pressure in a hydraulic cylinder is above some minimum value or compare it against the pump pressure. If you log simulation data, you can later query, plot, and analyze it without rerunning the simulation.
Simscape™ Results Explorer is an interactive tool that lets you navigate and plot the simulation data logging results. You can use data logging and the Simscape Results Explorer to view simulation results, instead of adding sensors and scopes to your model.
|Simscape Results Explorer
|Navigate and plot simulation data logging results
|Save logged simulation data in MLDATX file
|Create simulation log variable to access data in MLDATX file
|Plot logged simulation data for Node or Series
|Plot logged simulation data for one node or series against another
Node object corresponding to block or subsystem (Since R2020a)
|(To be removed) Find
Node object corresponding to block or
|Find path to node in logged simulation data tree (Since R2020a)
|(To be removed) Find path to node in logged simulation data tree
|Determine whether simulation log is current or stale (Since R2021a)
|Open Simscape Results Explorer to interact with logged simulation data
|Print zero crossing information for logged simulation data
- About Simulation Data Logging
You can log simulation data to the workspace, or to a temporary file on disk, for debugging and verification.
- Enable 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 the 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 the
y-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.
- View Sparkline Plots of Simulation Data
This example shows the basic workflow for viewing sparkline plots of logged simulation data for selected blocks and variables directly on the model canvas.
- 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.