# Guy and Seth on Simulink

## Comparing Runs using Simulation Data Inspector

Do you use the Simulation Data Inspector? Here is an example where it saved me a lot of debugging time.

Simulation Accuracy

I recently had to validate system behavior and analyze numerical accuracy of a model. Making small modifications in one part of the model was leading to unexpectedly large differences at the outputs. Since the model was very large, I thought it would be painful to insert Scopes or To Workspace blocks in the model to try identifying the source of the problem.

I found out that the Simulation Data Inspector can be very useful to compare simulation results without adding blocks to your model and without writing any scripts. Let's see how this work!

Logging Signals

The first step is to configure signals for logging. I like to use the Model Explorer for that. It is significantly faster than right-clicking on the signal lines one by one. Here are a few tips to configure the Model Explorer with the goal of controlling signal logging.

Also, ensure that signal logging is enabled in the model configuration.

Record & Inspect Simulation Output

In your model, click on the Record button.

When the simulation is completed, open the Simulation Data Inspector using the link that pops up.

Compare Runs

Make some changes to your model and simulate it again. In the Simulation Data Inspector, go to the Compare Runs Tab, select your 2 runs and click Compare.

Using the absolute tolerance I specified, the Simulation data Inspector helped me to quickly identify where the divergence appear in my model.

Give a look and the Validate System Behavior section of the documentation to learn more about the Simulation Data Inspector and let us know if it helps your workflow by leaving a comment here.

### 11 Responses to “Comparing Runs using Simulation Data Inspector”

1. Paul replied on :

So what was the problem?

2. Guy Rouleau replied on :

@Paul: I decided to not go into the details of the problem to keep the focus on using the Data Inspector for debugging.

The problem turned out that the model was using the deprecated Lookup Table and Lookup Table (2-D) blocks (See R2010a release notes for details). For some very specific input and table data, those blocks were giving slightly different results(+/- 1e-16) in Accelerator mode. Later in the model, the output of those blocks was multiplied by very large numbers, amplifying the difference.

Those blocks have been removed from the Simulink Library Browser since R2010a and replaced by the N-D Lookup table block. Executing SLUPDATE or running the Upgrade Advisor on the model replaced the block automatically and fixed the problem.

3. Eric replied on :

Guy, has their been thought about automatically running the Upgrade Advisor upon opening models? If some advice is triggered, then a dialog could be displayed with a description of what is found and then options to a) perform update(s), b) ignore this time, c) don’t run the tool in the future for this model, d) don’t run the tool automatically ever. So somewhat similar to the M-lint warning options…

4. Jim Ross replied on :

I have used Simulink Data Inspector from the time it was first introduced. No more scopes hidden across multiple levels of my models!

It certainly makes it easy to quickly look at results and to compare results across runs. I use it frequently to compare floating-point results to fixed-point results as well as compare results when I update a model.

5. Guy Rouleau replied on :

@Eric, automatically running the Upgrade Advisor when opening a model is something we considered and are still considering. The main concern right now is that it would slow things down too significantly.

6. Eric replied on :

Thanks Guy, understood – especially with some of the huge models that some folks build… What about only triggering the automatic SLUPDATE request if the model was created in a version of Simulink ‘X versions’ behind the version of SL that is opening it?

7. Guy Rouleau replied on :

I agree with you that this would be a good tradeoff. I cannot guarantee anything, but I have a feeling this will happen sometime soon.

8. Csaba replied on :

Hello,

In R2012b when I log a bus signal, the Simulation Data Inspector shows the name of the signal in the “Signal Name” column as bus_name.element_name, what is great.
I recently changed to R2013a, where the element_name is missing in the Signal Name column.

Am I missing some settings, or the feature has been changed?

Thank you.
Best regards,
Csaba

9. Ionis replied on :

Hi,

i am a new user of Simulation Data Inspector. I am trying to import a .mat file in the Inspector in order to compare the two signals that the file contains. Specifically, the mat file has 3 columns, the first column is the time, the second the voltage and the third the current. I open the Simulation Data Inspector, then press the import data button and afterwards i select ‘Import from’ –> ‘Mat file’ and then i select the mat.file. I press ok but there aren’t any signals in the ‘inspect signals’ tab. What is the problem? It is supposed that the Simulation Data Inspector imports data from a .mat file.
Thank you very much for your time!

10. Guy Rouleau replied on :

@Ionis: The “Import data” Simulation Data Inspector cannot recognize automatically that the first column should be time, and the two others data. For the inspector to recognize your data, I recommending creating a MATLAB timseries form it, with a syntax like “timeseries(data,time)”.

11. Lysimachos replied on :

Hi,

I am using the Simulink tool Simulation Data inspector in order to validate data. Each time I run it, I have to validate some signals which are the same each time. However, it is very time consuming each time I run the simulation data inspector to select again and again the same signals in order to inspect them. I searched on Mathworks forum in order to find some answers but I couldn’t. Could you be kind to tell me how this could be done? I uploaded a photo in order to show you how I want the default signals to look like. As you can see from the photo each time i want to check 9 graphs in which there are displayed the same default signals each time. So, i want each time i run the Simulation Data Inspector, the ‘inspect signals’ tab to be open and automatically the 9 graphs to be created.

 Name (required) E-mail (required, will not be published) Website (optional) Spam protection (required): What is 6 + 8 ?

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>


If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).

Guy Rouleau and Seth Popinchalk are Application Engineers for MathWorks. They write here about Simulink and other MathWorks tools used in Model-Based Design.

These postings are the author's and don't necessarily represent the opinions of MathWorks.