Products & Services Industries Academia Support User Community Company

Learn more about Simulink   

simplot - Plot simulation data in figure window

Syntax

simplot(data);
simplot(time, data);
simplot(data, ports);
simplot(data, 'diff')
simplot(time, data, ports, 'diff')

Description

The simplot command plots output from a simulation in a Handle Graphics® figure window. The plot looks like the display on the screen of a Scope block. Plotting the output on a figure window allows you to annotate and print the output.

The data to be plotted can be either a data structure or a matrix of the form produced by Simulink output blocks.

Specifying a Separate Time Vector

If data is a matrix or a structure without time, you can specify a separate time vector. time must be a vector with the same length as data.

Foe example:

simplot(time,data)

Specifying Specific Ports to Display

If data is a structure produced by a multi-port Scope block, the data from each port is displayed in a separate subplot. You can select specific ports to display by supplying a vector of port indices.

For example:

ports = [1,3];
simplot(data,ports)

plots the data from the first and third ports.

Overlaying Plots from Multiple Runs

If data is a cell array of structures or matrices, Simulink software overlays the plots from each element so that you can compare multiple runs. Each run is assumed to have identical structure. Line styles are used to differentiate between runs.

For example:

data = {run1, run2};
simplot(data)

overlays the data from run1 and run2.

You can use the 'diff' flag to display the differences between multiple runs. When you specify the 'diff' flag, Simulink software subtracts the first run from subsequent runs, and plots the results with the line style of the final run being compared.

For example:

data = {run1,run2};
simplot(data, 'diff')

plots run2run 1 using the line style of run2.

Combining Input Argument Options:

The options described above can be used in various combinations. All input arguments except for data are optional but when included must be entered in the following order:

simplot(time, data, ports, 'diff')

Obtaining Object Handles

You can obtain the handles for the plotted figure, its axes and lines using the simplot command:

Arguments

data

Data produced by one of the Simulink output blocks (for example, a root-level Outport block or a To Workspace block) or in one of the output formats used by those blocks: Array, Structure, Structure with time (see Data Import/Export Pane).

time

The vector of sample times produced by an output block when you have selected Array or Structure as the simulation's output format.

The simplot command ignores this argument if the format of the data is Structure with time.

ports

The vector of port indices from which to display data. If the data is a structure produced by a multi-port Scope block, the data from each port is displayed in a separate subplot.

'diff'

Displays the differences between multiple runs. When you specify the 'diff' flag, Simulink software subtracts the first run from subsequent runs, and plots the results with the line style of the final run being compared.

Examples

The following sequence of commands

vdp
set_param(gcs, 'SaveOutput', 'on')
set_param(gcs, 'SaveFormat', 'StructureWithTime')
sim(gcs)
simplot(yout)

plots the output of the vdp demo model on a figure window as follows.

See Also

sim, set_param, plot

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS