Main Content

Decide How to Visualize Simulation Data

Visualizing simulation data throughout the modeling process helps you understand and tune model behavior. Simulink®offers several complementary visualization tools you can use throughout the modeling process. Some visualization tools also offer the ability to save simulation data. Learn about each technique so you can choose the right tools to visualize your model data.

  • Simulation Data Inspector — View, analyze, and compare logged data throughout the modeling process.

  • Scope block,Floating Scopeblock, and Scope Viewer — Debug and analyze data using a block-based tool with capabilities similar to a bench-top oscilloscope.

  • Recordblock — Visualize data logged to the workspace, a file, or both.

  • Dashboard blocks — Build an interactive interface to tune and monitor a model.

  • Port value displays — View instantaneous signal values while debugging.

  • Custom MATLAB®visualization — Write MATLAB code to visualize data.

Simulation Data Inspector

You can use theSimulation Data Inspectorfor most visualization tasks. The Simulation Data Inspector integrates with data logging in your model and works well for visualizing many signals throughout a model. Use comparisons in the Simulation Data Inspector to prototype, debug, tune, calibrate, and test your models. The Simulation Data Inspector supports:

  • Viewing signals during simulation

  • Logging, importing, and exporting data

  • Configurable subplot layouts and visualization settings

  • 查看数据使用多个可视化选项,including maps and XY plots

  • Post-processing and data analysis using comparisons with tolerance values

  • Saving plots and data to share or archive results

The Inspect pane of the Simulation Data Inspector shows three subplots. The subplots show time plots of data gathered from three runs of the model sldemo_autotrans. The first subplot shows the EngineRPM signals from all three runs. The second subplot shows the ShiftLogic signals from all three runs. The third subplot shows the VehicleSpeed signal from all three runs.

To visualize simulation data using the Simulation Data Inspector, log data in the model. When you log signals and outputs, the logged data is automatically available in the Simulation Data Inspector during and after simulation. In the model Configuration Parameters, selectData Import/Export>Record logged workspace data in Simulation Data Inspectorto make logged states and Simscape™ data available in the Simulation Data Inspector after simulation. When you want to view signals without logging the data, consider using aScopeblock, theFloating Scopeblock, or aScope Viewer.

Open the Simulation Data Inspector fromSimulation>Data Inspectoror by clicking a signal logging badge. When you open the Simulation Data Inspector by clicking the logging badge on a signal, the signal is automatically plotted.

For more information, seeSimulation Data Inspector.

Scope Blocks and the Scope Viewer

Scopeblocks,Floating Scopeblocks, and theScope Viewervisualize connected signals in a similar way as a bench-top oscilloscope. The scope blocks and Scope Viewer use the same interface to visualize and analyze connected signals. The interface is similar to other domain-specific tools, such as theSpectrum Analyzer(DSP System Toolbox)andArray Plot(DSP System Toolbox)blocks.Scopeblocks are easy to add and connect in your model, and you do not need to log data in order to view signal data.

Scopeblocks,Floating Scopeblocks, and the Scope Viewer support:

  • Viewing signals during simulation, including rapid accelerator simulations

  • Simple connection and accessibility for lightweight debugging

  • Signal visualization without logging

  • Optional signal logging

  • Starting simulations from the visualization interface using playback controls

  • Oscilloscope measurements, including cursors and triggers. Additional measurements are available when you have a Simscape or DSP System Toolbox™ license

  • Configurable plots and display

  • Configurable triggers to capture events

Use theScopeblock, theFloating Scopeblock, and the Scope Viewer for prototyping and lightweight debugging. For example, in the early stages of model development, you can connect aScopeblock to a signal to quickly verify component behavior. By adding triggers, you can tune a specific peak or other artifact in a signal. AScopeblock may or may not be permanent in your model.

When you need to view data for signals throughout a model hierarchy, consider using the Simulation Data Inspector, especially if you already log the signals you want to view.

For more information, seeScope Blocks and Scope Viewer Overview.

Record Block

You can use theRecord, XY Graphblock to view connected signal data that you record to the workspace, a file, or both the workspace and a file.

TheRecordblock supports:

  • Viewing signals logged using theRecordblock during simulation

  • Logging data to the workspace, a file, and the Simulation Data Inspector

  • Streaming data to the Simulation Data Inspector during simulation

  • 查看数据使用多个可视化选项,including maps and XY plots

  • Starting simulations while viewing data in theRecordblock using simulation controls, such as theRunbutton

The Record block shows a sparklines visualization of three signals: Sine Wave, Chirp Signal, and Square Wave.

Connect signals to theRecordblock to log data to the workspace or a file. To view simulation data logged using theRecordblock, double-click the block. You can modify the plot layout and view data using several visualizations, including sparklines plots, time plots, and XY plots. Data logged to theRecordblock is automatically streamed to the Simulation Data Inspector during simulation. When you want to view signals without logging the data, consider using aScopeblock, theFloating Scopeblock, or aScope Viewer.

For more information, seeLog Data to the Workspace and a File Using the Record Block.

Dashboard Blocks

The Dashboard library includes control blocks you can use to tune variables and parameters in your model and visualization blocks you can use to view signal data. Use Dashboard blocks to view instantaneous signal data and build an interactive interface for your model.

You can use dashboard block controls to modify the values of variables and tunable parameters in your model during simulation. Visualization dashboard blocks are updated continuously throughout simulation. When you need to debug a model that uses dashboard blocks, consider using simulation pacing or simulation stepping to slow the simulation so you can view the instantaneous signal values. You can also promote dashboard blocks to one or more panels so the interactive dashboard can follow you throughout a model hierarchy as you design and debug your model. For more information, see:

TheDashboard Scope块提供了一个简单的视图的一个信号. You can zoom, pan, and add cursors to aDashboard Scopeblock through the context menu. For more debugging and analysis capabilities, use aScopeblock or log data to the Simulation Data Inspector.

For more information about using Dashboard blocks, seeTune and Visualize Your Model with Dashboard Blocks.

Port Value Displays

You can enable port value displays to view a signal value at a given time point. Port value displays can supplement existing visualizations while prototyping and debugging models. For example, you can view signal values on port value displays as you step through a simulation while visualizing the temporal behavior using aScope块。您还可以使用端口值显示在ir own to support debugging without adding any blocks to your model or logging data.

To display a signal value, right-click the signal and selectShow Value Label of Selected Port.

When inspecting signal data by displaying the value on the port, consider using simulation pacing or stepping through the simulation. For more information, seeSimulation PacingandStep Through Simulation.

For more information, seeDisplay Port Values for Debugging.

CustomMATLABVisualizations

When you log simulation data to the workspace or a file, you can write MATLAB code and scripts to create custom visualizations. You can log signals, outputs, and states in a model, and you can also enable data logging for signals connected to Scope Viewers,Floating Scopeblocks andScopeblocks. For more information about logging data in your model, seeSave Simulation Data.

Note

When you post-process data using MATLAB code and scripts, you do not need to write custom MATLAB code to visualize the data. You can import the processed data into the Simulation Data Inspector for visualization alongside the logged data.

The visualization code you write can depend on the format of the logged data. By default, logging uses theDatasetformat and produces a single simulation output. Logged data is returned to the workspace as aSimulink.SimulationOutputobject that contains aSimulink.SimulationData.Datasetobject for each type of logging used in the simulation. EachDatasetobject containsSimulink.SimulationData.Signalobjects that store the data for an individual signal as atimeseriesobject. For more information, seeData Format for Logged Simulation Data.

When you log a signal, you can visualize the signal during simulation using custom MATLAB code. For more information, seeAccess Data in a MATLAB Function During Simulation.

See Also

|||

Related Topics