Main Content

plot

Plot simulation results in Simulation Data Inspector

Description

example

plot(simRes) plots the simulation results in the object simRes in the Simulation Data Inspector and opens the Simulation Data Inspector. You can use the plot function to plot simulation results stored in these objects:

When the input object contains fewer than eight signals, the Simulation Data Inspector layout changes to 1-by-n, where n is the number of signals, and each subplot displays one signal. When the simulation results contain more than eight signals to plot, the Simulation Data Inspector layout changes to 1-by-1, and the plot displays the first signal.

When some or all of the data in a Simulink.SimulationOutput object is in a Simulation Data Inspector run, the plot function opens the Simulation Data Inspector and plots all the signals in the run. When the SimulationOutput object does not correspond to a run in the Simulation Data Inspector, the plot function imports the data into a new run.

When you use the plot function to plot a single signal, the plot function always imports the data for the signal into a new run.

These objects also have plot functions that plot data in the Simulation Data Inspector:

runObj = plot(simRes) returns the Simulink.sdi.Run object that corresponds to the plotted data.

Examples

collapse all

The model ex_vdp_simout_plot is configured to log signals, outputs, and states and return all logged data as a single simulation output. You can use the plot function to plot the simulation results in the Simulation Data Inspector.

Simulate the model. The model logs data using the Dataset format, so all the logged data streams to the Simulation Data Inspector during simulation.

open_system('ex_vdp_simout_plot')
out = sim('ex_vdp_simout_plot');

Use the plot function to plot all the simulation results in the Simulation Data Inspector. The Simulation Data Inspector updates to a 1-by-8 layout and plots one signal on each subplot.

plot(out)

You can also use the plot function to plot data for a single signal or a subset of the simulation results. When you plot the data for a single signal, the Simulation Data Inspector always imports the data for the signal into a new run.

The Simulink.SimulationOutput object contains a property for each logging variable. Access the signal logging data in the property logsout.

logsout = out.logsout;

Then, use the get function for the Dataset object to access the data for the first element, which contains the data for a single logged signal.

sig1 = get(logsout,1);

When you plot the data for the signal, the Simulation Data Inspector imports the signal into a new run, updates the layout to 1-by-1, and plots the signal.

plot(sig1)

Input Arguments

collapse all

Object that contains simulation data plot, specified in one of these forms:

Example: plot(out) plots the contents of the Simulink.SimulationOutput object out in the Simulation Data Inspector and opens the Simulation Data Inspector.

Output Arguments

collapse all

Run that corresponds to plotted data, returned as a Simulink.sdi.Run object.

Version History

Introduced in R2019b