| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
simplot(data); simplot(time, data); simplot(data, ports); simplot(data, 'diff') simplot(time, data, ports, 'diff')
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.
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)
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.
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.
Note If data contains Matrices or Structures without time, the data sets for all runs must be the same size. |
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 run2 — run 1 using the line style of run2.
Note Simulink software uses linear interpolation if the time vectors are not identical. If the start and stop times differ between runs, the difference is only plotted for the region of overlap. |
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')
You can obtain the handles for the plotted figure, its axes and lines using the simplot command:
hfig = simplot(data) — returns the figure handles.
haxes = simplot(data) — returns the handles for the figure axes.
hlins = simplot(data) — returns the handles for the lines in the figure.
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. |
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.

![]() | sim | simulink | ![]() |

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 |