plot
Plot logged simulation series values against time
Description
plots
the simulation series values along the fh
= plot(series
)y
-axis, with time along
the x
-axis. fh
is a structure of handles to
the resulting figures. series
is a
simscape.logging.Series
object. series
must include
a full identifier path to the series, starting with the workspace log variable name.
lets you customize the plot by using one or more fh
= plot(series
,Name,Value
)Name,Value
pair
arguments. For example, specify 'time
' followed by a 1x2 vector,
[
, to plot only the data within this time
range.start_time
end_time
]
Examples
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:
openExample('simscape/MassSpringDamperWithControllerExample')
This example model has data logging enabled for the whole model, with the
Workspace variable name parameter set to
simlog_MassSpringDamperWithController
.
Simulate the model to log the simulation data:
sim('MassSpringDamperWithController');
Plot velocity of port R of the Translational
Spring block Spring
.
plot(simlog_MassSpringDamperWithController.Spring.R.v.series);
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.
plot(simlog_MassSpringDamperWithController.Spring.R.v.series,'units','mm/s','time',[2 7]);
Input Arguments
series
— Simulation data to plot
scalar Series
object | nonscalar Series
object | cell array of Series
objects
Simulation data to plot, specified as a simscape.logging.Series
object or a homogeneous cell array of such objects. series
must
include a full identifier path to the series, starting with the workspace log variable
name.
The table describes the resulting plots based on the type of the
series
argument:
Scalar | Plots the simulation series values along the
|
Nonscalar | 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 |
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
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.
Example: fh =
plot(simlog.Translational_Spring.R.v.series,'units','mm/s')
plots velocity of
port R of the Translational Spring block
in mm/s
.
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
elements of series
.
By default, plots have no legend.
time
— Time range for plotting data
[ ] (default) | 1x2 vector, [start_time
end_time
]
in seconds
start_time
end_time
]Time range for plotting the data, specified as the comma-separated pair consisting
of 'time
' and a 1x2 vector,
[
, in seconds.start_time
end_time
]
[]
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
series values.
Output Arguments
fh
— Handles to the resulting plot figure windows
cell array
Handles to the resulting plot figure windows, returned as a cell array.
Version History
Introduced in R2010b
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)