This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Simulation Data Inspector

Inspect and compare data and simulation results to validate and iterate model designs

Description

The Simulation Data Inspector visualizes and compares multiple kinds of data.

Using the Simulation Data Inspector, you can inspect and compare time series data at multiple stages of your workflow. This example workflow shows how the Simulation Data Inspector supports all stages of the design cycle:

  1. View Data with the Simulation Data Inspector.

    Run a simulation in a model configured to log data to the Simulation Data Inspector, or import data from the workspace or a MAT-file. You can view and verify model input data or inspect logged simulation data while iteratively modifying your model diagram, parameter values, or model configuration.

  2. Inspect Simulation Data.

    Plot signals on multiple subplots, zoom in and out on specified plot axes, and use data cursors to understand and evaluate the data. Create Plots Using the Simulation Data Inspector to tell your story.

  3. Compare Simulation Data

    Compare individual signals or simulation runs and analyze your comparison results with relative, absolute, and time tolerances. The compare tools in the Simulation Data Inspector facilitate iterative design and allow you to highlight signals that do not meet your tolerance requirements. For more information about the comparison operation, see How the Simulation Data Inspector Compares Data.

  4. Save and Share Simulation Data Inspector Data and Views.

    Share your findings with others by saving Simulation Data Inspector data and views.

You can also harness the capabilities of the Simulation Data Inspector from the command line. For more information, see Inspect and Compare Data Programmatically.

Open the Simulation Data Inspector

  • Simulink® Editor toolbar: Click the Simulation Data Inspector icon.

  • Click the streaming badge on a signal to open the Simulation Data Inspector and plot the signal.

  • MATLAB® command prompt: Enter Simulink.sdi.view.

Examples

expand all

This example shows how to use Simulink.sdi.createRunOrAddToStreamedRun to add data to an existing run for a model. In this example, you add logged states data to the run created through simulation.

Simulate the Model

Simulate the model to generate data. The model slexAircraftExample is configured to log outputs, so the Simulation Data Inspector automatically creates a run with the logged outport data. Using this simulation syntax, out contains the outport data (yout) and the states data (xout).

load_system('slexAircraftExample')
out = sim('slexAircraftExample','ReturnWorkspaceOutputs','on',...
            'SaveFormat','Dataset');

Add Logged States Data to Run

The Simulation Data Inspector automatically created a run for the logged outport data. Add the logged state data to the existing run using Simulink.sdi.createRunOrAddToStreamedRun.

Simulink.sdi.createRunOrAddToStreamedRun('slexAircraftExample','Run 1',...
              {'out'},{out});

Open the Simulation Data Inspector to View Results

Using Simulink.sdi.createRunOrAddToStreamedRun avoids redundancy in the data shown in the Simulation Data Inspector. Using Simulink.sdi.createRun to bring the states data into the Simulation Data Inspector creates a second run. Simulink.sdi.addToRun creates a duplicate signal from the outport data. Using Simulink.sdi.createRunOrAddToStreamedRun, you can include all simulation data in a single run without duplicating any signals.

Simulink.sdi.view

This example shows how to modify a parameter for all the runs in the Simulation Data Inspector programmatically.

Generate Runs

Load the vdp model and mark the x1 and x2 signals for logging. Then, run several simulations.

% Clear all data from the Simulation Data Inspector repository
Simulink.sdi.clear

% Load the model and mark signals of interest for streaming
load_system('vdp')
Simulink.sdi.markSignalForStreaming('vdp/x1',1,'on')
Simulink.sdi.markSignalForStreaming('vdp/x2',1,'on')

% Simulate the model with several Mu values
for gain = 1:5
    gainVal = num2str(gain);
    set_param('vdp/Mu','Gain',gainVal)
    sim('vdp')
end

Use Simulink.sdi.getRunCount to Assign Tolerance to x1 Signals

count = Simulink.sdi.getRunCount;

for a = 1:count
    runID = Simulink.sdi.getRunIDByIndex(a);
    vdpRun = Simulink.sdi.getRun(runID);
    sig = vdpRun.getSignalByIndex(1);
    sig.AbsTol = 0.1;
end

% Open the Simulation Data Inspector to view your data
Simulink.sdi.view

Related Examples

Programmatic Use

expand all

Simulink.sdi.view opens the Simulation Data Inspector from the MATLAB command line.

Introduced in R2010b