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.
|On this page…|
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 step in setting up a referenced model to view signals using the Simulation Data Inspector is to setup that model for logging. In order to do that, you need to edit the referenced model and mark the signals for logging, as follows:
Select the signals that you would like to log.
Select the menu item Log/Unlog Selected Signals on the Record button 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. To do this, open the Simulink Signal Logging Selector dialog, using Configuration Parameters > Data Import/Export > Configure Signals to Log.
There are two Logging modes that can be used when logging signals in referenced models. The first is Log all signals as specified, 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, 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 documentationdocumentation for more details on using the Simulation Data Inspector.
With the Simulation Data Inspector, you can:
View signal traces for any logged signals
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 Notification bar at the top of your model with a link to 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 9 and simulate the model again to see how that affects output values.
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 9, as expected. The red octagon next to each signal indicates that the values have changed between runs.