plot

Plot simulation output data in the Simulation Data Inspector

Description

example

plot(simOutObj) plots the simulation output data in the simulation output object, simOutObj, in the Simulation Data Inspector and opens the Simulation Data Inspector so you can view the plotted simulation output data. You can use the plot function to plot simulation results stored in these simulation output objects:

These simulation output objects also have plot functions that plot the data in and then open the Simulation Data Inspector:

When a simulation output object contains fewer than eight signals to plot, the Simulation Data Inspector layout changes to 1-by-n, where n is the number of signals to plot, and plots one signal on each subplot. When the simulation output object contains more than eight signals to plot, the Simulation Data Inspector layout changes to 1-by-1 and plots the first signal in the simulation output object.

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 data does not correspond to a run in the Simulation Data Inspector, the plot function imports the data to a new run. When you use the plot function to plot a single signal, the plot function always imports the data for the signal to a new run.

runObj = plot(simOutObj) returns the Simulink.sdi.Run object corresponding to the plotted data.

Examples

collapse all

The ex_vdp_simout_plot model used in this example is configured to log signals, outputs, and states and return all logged data in a single simulation output. The single simulation output is a Simulink.SimulationOutput object that contains one or more types of other simulation output objects, depending on the kinds of data you log. This example shows how to access each type of logged data and use the plot function to plot the data in the Simulation Data Inspector. To generate the SimulationOutput object containing all the logged data, simulate the model.

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

Plot Data in a SimulationOutput Object

You can pass the single simulation output, stored in a Simulink.SimulationOutput object, to the plot function to view the data in the Simulation Data Inspector. When you plot data in a SimulationOutput object that corresponds to a run in the Simulation Data Inspector, data in the object that also logs to the Simulation Data Inspector is plotted. The model logs data using the Dataset format, so all logged data streams to the Simulation Data Inspector.

When you use the plot function to plot the data, the Simulation Data Inspector updates to a 1-by-8 layout and plots one signal on each subplot.

plot(out)

Plot Data for a Single Signal

When you plot the data for a single signal, the Simulation Data Inspector always imports the data for the signal to a new run. Use the get function for the SimulationOutput object to access the signal logging Dataset object, logsout.

logsout = get(out,'logsout');

Then, use the get function for the Dataset object to access the data for the first element.

sig1 = get(logsout,1);

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

plot(sig1)

Input Arguments

collapse all

Simulation output object containing data you want to plot and view in the Simulation Data Inspector. This plot function supports these simulation output objects:

Example: plot(out)

Output Arguments

collapse all

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

Introduced in R2019b