This example shows how to use the Simulation Data Inspector to view and analyze signals in referenced models. The Simulation Data Inspector relies on signal logging so this example shows how to configure your model to log signals in referenced models.
Run the following command to create and open a working copy of the project files.
The project example copies files to your temporary folder so that you can edit them and use them under local version control.
The Simulink® Project Tool opens and loads the project already under version control.
The project is configured to run some startup tasks.
The first task in setting up a referenced model to view signals using the Simulation Data Inspector is to set up that model for logging. To do that, edit the referenced model and mark the signals for logging. Note that four signals are already set up for logging (marked with the blue antennas). To log an additional signal:
Select the raw output signal
Click the Simulink Data Inspector button and select the
Log Selected Signals to Workspace menu item, as shown below
Once the signals to log have been selected in the referenced model, the next step is to select which signals to actually log from the topmost model in the hierarchy. Selecting the
Configure Logging and Streaming... menu item on the top model's Record button activates the
Configuration Parameters > Data Import/Export pane.
Configure Signals to Log... button to activate the Simulink Signal Logging Selector dialog.
There are two Logging modes that can be used when logging signals in referenced models. The first is
Log all signals as specified in model, which will honor any logging settings that were made in referenced models. If you need to override any of those settings, such as selecting only a subset of logged signals, then you should use the
Override signals mode. In this mode, you are given the ability to select a subset of loggable signals and configure their properties, such as decimation and name.
Once logging has been configured for a model hierarchy and all changes to the models have been saved, the model can be simulated. The simulation creates a Dataset object in the base workspace. You can analyze and view the logged data in this object using standard MATLAB tools. In addition, Simulink provides the Simulation Data Inspector, for viewing and analyzing data created from simulations. See the documentation for more details on using the Simulation Data Inspector.
With the Simulation Data Inspector, you can:
View signal traces for any logged signals
Visually compare signal values for any logged signals
Compare signal values collected over multiple simulations
To enable the Simulation Data Inspector, make sure that the Record button on the toolbar of the topmost model is toggled on before starting the simulation. Then after a simulation is done or while using the Simulation Stepper you will see a highlight around the Record button, which indicates that clicking it will open the Data Inspector.
For example, you can use the Simulation Data Inspector to compare the
output signal of two of the instances of the model
LimitedCounter. As shown below, you can see that
CounterA increases more rapidly than
CounterB, which is expected because the Pulse Generator driving this model is running at a faster rate.
Another useful tool that the Simulation Data Inspector provides is the ability to compare multiple simulation runs. This functionality can help you understand how changes to your model will affect results. For example, you can change the value of the upper limit of the counter models to 8 and simulate the model again to see how that affects output values. To change the value, double click on the block
MultiInstanceModelExample/upper and modify the Value parameter to 8.
Now if you compare the results from the first simulation for the output of the
CounterA instance of
LimitedCounter, you see that the upper limit of this signal has changed from 10 to 8, as expected. The red octagon next to each signal indicates that the values have changed between runs.