Create trajectory plotter
creates a trajectory plotter for use with the theater plot trajPlotter
= trajectoryPlotter(tp
)tp
.
creates a trajectory plotter with additional options specified by one or more
trajPlotter
= trajectoryPlotter(tp
,Name,Value
)Name,Value
pair arguments.
This example shows how to create an animation of a platform moving on a trajectory.
First, create a trackingScenario
and add waypoints for a trajectory.
ts = trackingScenario;
height = 100;
d = 1;
wayPoints = [ ...
-30 -25 height;
-30 25-d height;
-30+d 25 height;
-10-d 25 height;
-10 25-d height;
-10 -25+d height;
-10+d -25 height;
10-d -25 height;
10 -25+d height;
10 25-d height;
10+d 25 height;
30-d 25 height;
30 25-d height;
30 -25+d height;
30 -25 height];
Specify a time for each waypoint.
elapsedTime = linspace(0,10,size(wayPoints,1));
Next, create a platform in the tracking scenario and add trajectory information using the trajectory
method.
target = platform(ts); traj = waypointTrajectory('Waypoints',wayPoints,'TimeOfArrival',elapsedTime); target.Trajectory = traj;
Record the tracking scenario to retrieve the platform's trajectory.
r = record(ts); pposes = [r(:).Poses]; pposition = vertcat(pposes.Position);
Create a theater plot to display the recorded trajectory.
tp = theaterPlot('XLim',[-40 40],'YLim',[-40 40]); trajPlotter = trajectoryPlotter(tp,'DisplayName','Trajectory'); plotTrajectory(trajPlotter,{pposition})
Animate using the platformPlotter
.
restart(ts); trajPlotter = platformPlotter(tp,'DisplayName','Platform'); while advance(ts) p = pose(target,'true'); plotPlatform(trajPlotter, p.Position); pause(0.1) end
This animation loops through all the generated plots.
tp
— Theater plottheaterPlot
objectTheater plot, specified as a theaterPlot
object.
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
.
'LineStyle','--'
'DisplayName'
— Plot name to display in legendPlot name to display in legend, specified as the comma-separated pair consisting of 'DisplayName'
and a character vector or string scalar. If no name is specified, no entry is shown.
Example: 'DisplayName','Radar Detections'
'Color'
— Trajectory color'gray'
(default) | character vector | string scalar | RGB triplet | hexadecimal color codeTrajectory color, specified as the comma-separated pair consisting of
'Color'
and a character vector, a string scalar, an RGB
triplet, or a hexadecimal color code.
'LineStyle'
— Line style':'
(default) | '-'
| '--'
| '-.'
Line style used to plot the trajectory, specified as one of these values.
Value | Description |
---|---|
':' | Dotted line (default) |
'-' | Solid line |
'--' | Dashed line |
'-.' | Dash-dotted line |
'LineWidth'
— Line width0.5
(default) | positive scalarLine width of the trajectory, specified in points size as the comma-separated pair
consisting of 'LineWidth'
and a positive scalar.
'Tag'
— Tag to associate with the plotter'PlotterN'
(default) | character vector | string scalarTag to associate with the plotter, specified as the comma-separated pair
consisting of 'Tag'
and a character vector or string scalar. The
default value is 'PlotterN'
, where
N is an integer that corresponds to the Nth
plotter associated with the theaterPlot
.
Tags provide a way to identify plotter objects, for example when searching using
findPlotter
.
You have a modified version of this example. Do you want to open this example with your edits?