Main Content

plot

Plot trajectory data

Since R2024b

Description

plot(trajectory) plots trajectories in the input Trajectory object trajectory.

plot(trajectory,Name=Value) specifies options using one or more name-value arguments. For example, MarkerSize=5 plots the GPS waypoints with a marker size of 5.

example

figHandle = plot(___) returns a figure handle as a Line object using any combination of input arguments from previous syntaxes.

Note

This function requires the Scenario Builder for Automated Driving Toolbox™ support package. You can install the Scenario Builder for Automated Driving Toolbox support package from the Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

Examples

collapse all

Load recorded GPS trajectory data into the workspace.

load("recordedGPSData.mat","X","Y","Z","timestamps")

Create a trajectory object by using the loaded timestamps and xyz-coordinates.

traj1 = scenariobuilder.Trajectory(timestamps,X,Y,Z)
traj1 = 
  Trajectory with properties:

               Name: ''

         NumSamples: 392
           Duration: 19.5498
         SampleRate: 20.0513
         SampleTime: 0.0500
         Timestamps: [392×1 double]

           Position: [392×3 double]
        Orientation: [392×3 double]
           Velocity: [392×3 double]
             Course: [392×1 double]
        GroundSpeed: [392×1 double]
       Acceleration: [392×3 double]
    AngularVelocity: [392×3 double]

        LocalOrigin: [0 0 0]
         TimeOrigin: 0

         Attributes: []

Plot the trajectory object.

plot(traj1,ShowZ=true,ShowSpeed=true,ShowVelocity=true,LineWidth=0.1,MarkerSize=1)

Combine the xyz-coordinates into a waypoint matrix, and create another trajectory by using the timestamps and waypoints.

waypoints = [X Y Z];
traj2 = scenariobuilder.Trajectory(timestamps,waypoints)
traj2 = 
  Trajectory with properties:

               Name: ''

         NumSamples: 392
           Duration: 19.5498
         SampleRate: 20.0513
         SampleTime: 0.0500
         Timestamps: [392×1 double]

           Position: [392×3 double]
        Orientation: [392×3 double]
           Velocity: [392×3 double]
             Course: [392×1 double]
        GroundSpeed: [392×1 double]
       Acceleration: [392×3 double]
    AngularVelocity: [392×3 double]

        LocalOrigin: [0 0 0]
         TimeOrigin: 0

         Attributes: []

Plot the trajectory object.

plot(traj2,ShowHeading=true,ShowOrientation=true,LineWidth=0.1,MarkerSize=1)

Input Arguments

collapse all

Trajectory with timestamps and waypoints, specified as a Trajectory object.

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.

Example: plot(trajectory,MarkerSize=5) plots the trajectories with a marker size of 5.

Parent figure, specified as a Figure object or Panel object. If you do not specify Parent, the function plots the trajectory in a new figure.

Plot z-coordinates across timestamps, specified as a logical 1 (true) or 0 (false).

Data Types: logical

Plot speed values across timestamps, specified as a logical 1 (true) or 0 (false).

Data Types: logical

Plot heading angles across timestamps, specified as a logical 1 (true) or 0 (false).

Data Types: logical

Plot orientation angles across timestamps, specified as a logical 1 (true) or 0 (false).

Data Types: logical

Plot velocity values across timestamps, specified as a logical 1 (true) or 0 (false).

Data Types: logical

Plot acceleration values across timestamps, specified as a logical 1 (true) or 0 (false).

Data Types: logical

Plot angular velocity values across timestamps, specified as a logical 1 (true) or 0 (false).

Data Types: logical

Line style, marker, and color, specified as a string scalar or character vector containing symbols. For more information, see LineSpec in another plot function.

Data Types: string | char

Line width, specified as a positive scalar in points, where 1 point = 1/72 of an inch. If the line has markers, then the line width also affects the marker edges.

The line width cannot be thinner than the width of a pixel. If you set the line width to a value that is less than the width of a pixel on your system, the line displays as one pixel wide.

Data Types: double

Marker size, specified as a positive scalar in points, where 1 point = 1/72 of an inch.

Data Types: double

Marker fill color, specified as "none", "auto", an RGB triplet, a hexadecimal color code, a color name, or a short color name. The "auto" option uses the same color as the Color property of the parent axes. If you specify "auto" and the axes plot box is invisible, the marker fill color is the color of the figure. For more information, see MarkerFaceColor in another plot function. The "none" option renders the markers without a fill color.

Number of points to skip between heading makers, specified as a positive integer. This value must be between 0 and the value of NumSamples property of the input trajectory object.

Data Types: uint8 | uint16 | uint32 | uint64

Orientation units, specified as "radians" or "degrees".

Data Types: string | char

Line color, specified as an RGB triplet, a hexadecimal color code, a color name, or a short color name. For more information, see Color in another plot function.

Output Arguments

collapse all

Figure handle, returned as a Figure object. You can use the figure handle to query and modify figure properties. For more information, see Figure Properties.

Version History

Introduced in R2024b