Plot logged simulation series values against time
the simulation series values along the
fh = plot(
y-axis, with time along
fh is a structure of handles to
the resulting figures.
series is a
series must include
a full identifier path to the series, starting with the workspace log variable name.
Plot Simulation Data for a Series
Plot velocity of port R of a Translational Spring block.
Open the Mass-Spring-Damper with Controller example model:
This example model has data logging enabled for the whole model, with the
Workspace variable name parameter set to
Simulate the model to log the simulation data:
Plot velocity of port R of the Translational
Customize the Plot
Customize the previous plot using the name-value pair arguments.
This command plots the velocity of port R of the Translational Spring block in mm/s and only within the time range between 2 and 7 seconds.
series — Simulation data to plot
Series object | nonscalar
Series object | cell array of
Simulation data to plot, specified as a
object or a homogeneous cell array of such objects.
include a full identifier path to the series, starting with the workspace log variable
The table describes the resulting plots based on the type of the
Plots the simulation series values along the
Plots each dimension of the series values on a different axis in the same figure window.
Cell array of
Plots all series objects with commensurate units on the same axis (superimposed), and each dimension for a nonscalar series on a different axis in the same figure window.
The input arguments are binned based on
commensurate units. For each bin, all
Specify optional pairs of arguments as
the argument name and
Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name in quotes.
plot(simlog.Translational_Spring.R.v.series,'units','mm/s') plots velocity of
port R of the Translational Spring block
names — Plot legend
cell array of character vectors or string scalars
Plot legend, specified as the comma-separated pair consisting of
names' and a cell array of character vectors or string
scalars. The number of elements in the cell array must be same as the number of
By default, plots have no legend.
time — Time range for plotting data
[ ] (default) | 1x2 vector,
[ in seconds
Time range for plotting the data, specified as the comma-separated pair consisting
time' and a 1x2 vector,
[, in seconds.
 plots all data.
units — Units for plotting data
character vector | string scalar | cell array of character vectors or string scalars
Units for plotting the data, specified as the comma-separated pair consisting of
units' and a unit name, or a cell array of unit names. Unit
names must appear inside single quotes (
'') or double quotes
""). Specified units must be commensurate with the units of the
fh — Handles to the resulting plot figure windows
Handles to the resulting plot figure windows, returned as a cell array.
Introduced in R2010b