Main Content

simscape.logging.plotxy

Plot logged simulation data for one node or series against another

Description

example

fh = simscape.logging.plotxy(x,y) plots the simulation series values of object y along the y-axis, with series values of object x along the x-axis. x and y can be simscape.logging.Series objects, simscape.logging.Node objects, or homogeneous cell arrays of such objects. If x or y is a node, it must be a simulation variable node (one that has a direct child series). The values of this child series are then plotted along the respective axis.

If x and y are cell arrays, they must be of the same size, or one of them can be a scalar. x and y must have the same time vectors.

fh is a cell array of figure handles, one for each y versus x plot generated.

example

fh = simscape.logging.plotxy(x,y,Name,Value) lets you customize the plot by using one or more Name,Value pair arguments. For example, specify 'time' followed by a 1x2 vector, [start_time end_time], to plot only the data within this time range.

Examples

collapse all

Plot the motor torque against its angular velocity, in default units.

Open the Permanent Magnet DC Motor example model:

ssc_dcmotor

This example model has data logging enabled for the whole model, with the Workspace variable name parameter set to simlog_ssc_dcmotor.

Simulate the model to log the simulation data:

sim('ssc_dcmotor');

Plot the motor torque against its angular velocity:

simscape.logging.plotxy(simlog_ssc_dcmotor.DC_Motor.Rotational_Electromechanical_Converter.R.w,...
   simlog_ssc_dcmotor.DC_Motor.Inertia.t)

Plot the motor torque, in default units, against its angular velocity, in rpm, and add axis names.

simscape.logging.plotxy(simlog_ssc_dcmotor.DC_Motor.Rotational_Electromechanical_Converter.R.w,...
   simlog_ssc_dcmotor.DC_Motor.Inertia.t,'xunit','rpm','xname','Angular velocity','yname','Torque')

Input Arguments

collapse all

Simulation data to plot along the x-axis, specified as a simscape.logging.Series object, simscape.logging.Node object, or a homogeneous cell array of such objects. x must include a full identifier path to the node or series, starting with the workspace log variable name.

If x is a node, it must be a simulation variable node (one that has a direct child series). The values of this child series are then plotted along the x-axis.

If x and y are cell arrays, they must be of the same size, or one of them can be a scalar. x and y must have the same time vectors.

Simulation data to plot along the y-axis, specified as a simscape.logging.Series object, simscape.logging.Node object, or a homogeneous cell array of such objects. y must include a full identifier path to the node or series, starting with the workspace log variable name.

If y is a node, it must be a simulation variable node (one that has a direct child series). The values of this child series are then plotted along the y-axis.

If x and y are cell arrays, they must be of the same size, or one of them can be a scalar. x and y must have the same time vectors.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: fh = simscape.logging.plotxy(simlog.TS.C.v.series,simlog.TS.R.v.series,'xunit','mm/s','yunit','mm/s') plots velocities of ports C and R of the Translational Spring block TS against each other, in mm/s.

Time range for plotting the data, specified as the comma-separated pair consisting of 'time' and a 1x2 vector, [start_time end_time], in seconds.

[] plots all data.

Name of the plot x-axis, specified as the comma-separated pair consisting of 'xname' and a character vector, string scalar, or 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 x.

Name of the plot y-axis, specified as the comma-separated pair consisting of 'yname' and a character vector, string scalar, or 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 y.

Unit for plotting the data along the x-axis, specified as the comma-separated pair consisting of 'xunit' 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.

Unit for plotting the data along the y-axis, specified as the comma-separated pair consisting of 'xunit' 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

collapse all

Handles to the resulting plot figure windows, one for each y versus x plot generated, returned as a cell array.

Introduced in R2010b