Simulation with Data Import and Signal Inspection

Data Import and Logging Workflow

Simulink® provides two features to import data and view
simulation results: the Signal Builder block and the
Simulation Data Inspector. Use the Signal Builder block
to import input signals into your model. The Simulation Data Inspector
allows you to view model output signals and compare them.

Example Used in this Tutorial

sldemo_2counters is a Simulink model
that includes a Signal Builder block and two subsystems.
Each subsystem is a counter circuit.

Enabled Subsystem — Increments the counter
when the subsystem is enabled and subsequently retains its output
while the subsystem is disabled. Because the Enable port is configured
to reset states when enabling, the counter returns to zero when the
subsystem is re-enabled.

Triggered Subsystem — Increments the counter
for each rising edge of the control signal.

ex_signaldata.xls is a Microsoft Excel file.
It contains two sets of input data on two sheets. The first set of
input data is a square wave to test the model response to an impulse.
The second set of input data is a triangular wave to test the model
response to a ramp signal.

The example model with a Signal Builder block opens in a Simulink editor
window.

Double-click the Signal Builder block.
A Signal Builder window opens and displays one data group with an
Amplitude signal.

From the Signal Builder menu, select Group > Copy. A second group named Group 2 appears
in the Active Group drop-down list.

Select Group > Rename, and enter more meaningful
names that describe the input data. For example, rename Group 1 and
Group 2 to Impulse Input and Ramp Input.

Importing Data from Excel Spreadsheets

Simulink saves data imported from an Excel file using
a Signal Builder block with the model and loads the data into memory
when you open the model. If you have large sets of data, consider
using a MAT-file with the Inport block.

Compare Signals

The Simulation Data Inspector allows you to quickly compare
and inspect signals between different runs.

In the Simulation Data Inspector window, click the Compare tab.
By default, Run 1 and Run 2 are selected for comparison in the Baseline and Compare
To drop-down lists.

Click the Compare Runs button
to compare each signal between the Baseline and Compare
To runs. The Simulation Data Inspector switches to the Comparisons pane
to show all of the signal comparisons.

Select the Enable Counter radio
button to plot the comparison.

Inspect the signals. The top plot contains the two individual
signals from each run. The bottom plot represents the difference between
the two signals and the tolerance value. In this case, the tolerance
is zero. Since the difference is greater than zero, the comparison
is not within the tolerance.