values
Extract values vector from simulation series
Description
Examples
Extract Spring Deformation Values
Return the deformation values of a Translational Spring block, in default units.
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 for 1 second, to log the simulation data:
paramNameValStruct.StopTime = '1.0'; sim('MassSpringDamperWithController',paramNameValStruct);
Return the deformation values of the Translational
Spring block, Spring
. x
is the
deformation variable name, and series
is the Series
object containing the simulation data for this variable.
v1 = values(simlog_MassSpringDamperWithController.Spring.x.series)
v1 = 0 0.0652 0.1153 0.1587 0.1947 0.2179 0.2228 0.2046 0.1591 0.0840 0.0193 -0.0164 -0.0426 -0.0648 -0.0762 -0.0770 -0.0747 -0.0686 -0.0587 -0.0519 -0.0452 -0.0369 -0.0282 -0.0231 -0.0187 -0.0140 -0.0097 -0.0074 -0.0054 -0.0036 -0.0021 -0.0011 -0.0005 -0.0002 -0.0000
The v1
vector has 35 values because the simulation series has 35
time steps. The deformation values are in meters (the default unit of the
series).
Extract Spring Deformation Values in Different Unit
The previous example returns the deformation values of a Translational Spring block in default units, meters. In this example, specify a different unit for extracting the series values. The unit you specify must be commensurate with the default units of the variable values contained in the series.
Return the deformation values of the Translational
Spring block, Spring
, in millimeters.
v2 = values(simlog_MassSpringDamperWithController.Spring.x.series,'mm')
v2 = 0 65.1626 115.2876 158.6666 194.6648 217.8816 222.7924 204.5943 159.1137 83.9882 19.3122 -16.4485 -42.6109 -64.7991 -76.1640 -76.9521 -74.6976 -68.5525 -58.6695 -51.8953 -45.1768 -36.8985 -28.1789 -23.1087 -18.6816 -14.0093 -9.7345 -7.3590 -5.4308 -3.5878 -2.0621 -1.0952 -0.5459 -0.1758 -0.0334
The v2
vector also has 35 values, but these values are in
millimeters, so each value is 1000 times bigger than the respective value in
v1
.
Input Arguments
series
— Simulation series
Series
object
Simulation series, specified as a simscape.logging.Series
object.
series
must include a full identifier path to the series,
starting with the workspace log variable name.
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
vv
— Variable values corresponding to time steps in simulation series
row vector
Variable values corresponding to the time steps in the simulation series, returned as a row vector.
For nonscalar variables of size
m
-by-n
, this method returns a
row vector of
m
*n
*steps
size, where steps
is the number of steps in the series, and
each m
*n
block represents the
logged value for the variable in a column major form. For example, if a variable size is
2-by-2, then the first four elements in the row vector are the
a11
,
a21
,
a12
, and
a22
elements at the first time
step.
Version History
Introduced in R2010b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
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)