Main Content


Mesh plotter for bird's-eye plot



mPlotter = meshPlotter(bep) creates a MeshPlotter object that configures the display of meshes on a bird's-eye plot. The MeshPlotter object is stored in the Plotters property of the input birdsEyePlot object, bep. To display the mesh representations of objects, use the plotMesh function.

mPlotter = meshPlotter(bep,Name,Value) sets properties using one or more Name,Value pair arguments. For example, meshPlotter(bep,'FaceAlpha',1) sets the mesh faces to be fully opaque.


collapse all

Display actors in a driving scenario by using their mesh representations instead of their cuboid representations.

Create a driving scenario, and add a 25-meter straight road to the scenario.

scenario = drivingScenario;
roadcenters = [0 0 0; 25 0 0];

Add a pedestrian and a vehicle to the scenario. Specify the mesh dimensions of the actors using prebuilt meshes.

  • Specify the pedestrian mesh as a driving.scenario.pedestrianMesh object.

  • Specify the vehicle mesh as a driving.scenario.carMesh object.

p = actor(scenario,'ClassID',4, ...
            'Length',0.2,'Width',0.4, ...

v = vehicle(scenario,'ClassID',1, ...

Add trajectories for the pedestrian and vehicle.

  • Specify for the pedestrian to cross the road at 1 meter per second.

  • Specify for the vehicle to follow the road at 10 meters per second.

waypointsP = [15 -3 0; 15 3 0];
speedP = 1;

wayPointsV = [v.RearOverhang 0 0; (25 - v.Length + v.RearOverhang) 0 0];
speedV = 10;

Add an egocentric plot for the vehicle. Turn the display of meshes on.


Create a bird's-eye plot in which to display the meshes. Also create a mesh plotter and lane boundary plotter. Then run the simulation loop.

  1. Obtain the road boundaries of the road the vehicle is on.

  2. Obtain the mesh vertices, faces, and colors of the actor meshes, with positions relative to the vehicle.

  3. Plot the road boundaries and actor meshes on the bird's-eye plot.

  4. Pause the scenario to allow time for the plots to update. The chase plot updates every time you advance the scenario.

bep = birdsEyePlot('XLim',[-25 25],'YLim',[-10 10]);
mPlotter = meshPlotter(bep);
lbPlotter = laneBoundaryPlotter(bep);

while advance(scenario)

   rb = roadBoundaries(v);

   [vertices,faces,colors] = targetMeshes(v);



Input Arguments

collapse all

Bird’s-eye plot, specified as a birdsEyePlot object.

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: meshPlotter('FaceAlpha',0.5) sets the mesh faces to be 50% transparent.

Transparency of mesh faces, specified as the comma-separated pair consisting of 'FaceAlpha' and a scalar in the range [0, 1]. A value of 0 makes the mesh faces fully transparent. A value of 1 makes the mesh faces fully opaque.

Tag associated with the plotter object, 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 input birdsEyePlot object.

Output Arguments

collapse all

Mesh plotter, returned as a MeshPlotter object. You can modify this object by changing its property values. The property names correspond to the name-value pair arguments of the meshPlotter function.

mPlotter is stored in the Plotters property of the input birdsEyePlot object, bep. To plot the meshes, use the plotMesh function.

More About

collapse all


In driving scenarios, a mesh is a triangle-based 3-D representation of an object. Mesh representations of objects are more detailed than the default cuboid (box-shaped) representations of objects. Meshes are useful for generating synthetic point cloud data from a driving scenario.

This table shows the difference between a cuboid representation and a mesh representation of a vehicle in a driving scenario.


A vehicle represented as a cube.

A vehicle represented as a mesh.

Introduced in R2020b