Main Content

Programmatic Scenario Authoring

Programmatically create driving scenarios by using a drivingScenario object

The drivingScenario object enables you to author driving scenarios from the MATLAB® command line. Use this object to design complex road networks and specify actors and their trajectories. You can then generate synthetic detections or lidar point cloud data from these scenarios by using statistical sensor models. To use detections or point clouds, view them on a bird's-eye plot.

The flexible interface of the drivingScenario object enables you to create variations of a scenario for rapidly testing driving algorithms under various conditions. For more details, see Create Driving Scenario Variations Programmatically.


expand all


drivingScenarioCreate driving scenario
advanceAdvance driving scenario simulation by one time step
plotCreate driving scenario plot
recordRun driving scenario and record actor states
restartRestart driving scenario simulation from beginning
updatePlotsUpdate driving scenario plots
exportExport road network to OpenDRIVE


actorAdd actor to driving scenario
actorPosesPositions, velocities, and orientations of actors in driving scenario
actorProfilesPhysical and radar characteristics of actors in driving scenario
vehicleAdd vehicle to driving scenario
chasePlotEgo-centric projective perspective plot
trajectoryCreate actor or vehicle trajectory in driving scenario
targetMeshesMesh vertices and faces relative to specific actor
targetOutlinesOutlines of targets viewed by actor
targetPosesTarget positions and orientations relative to ego vehicle
driving.scenario.targetsToEgoConvert target poses from scenario to ego coordinates
driving.scenario.targetsToScenarioConvert target poses from ego to scenario coordinates


roadAdd road to driving scenario
roadNetworkAdd road network to driving scenario
roadBoundariesGet road boundaries
driving.scenario.roadBoundariesToEgoConvert road boundaries to ego vehicle coordinates
roadMeshMesh representation of roads near actor


currentLaneGet current lane of actor
lanespecCreate road lane specifications
laneTypeCreate road lane type object
laneMarkingCreate road lane marking object
laneMarkingVerticesLane marking vertices and faces in driving scenario
laneBoundariesGet lane boundaries of actor lane
clothoidLaneBoundaryClothoid-shaped lane boundary model
computeBoundaryModelCompute lane boundary points from clothoid lane boundary model
radarDetectionGeneratorGenerate radar detections for driving scenario
visionDetectionGeneratorGenerate vision detections for driving scenario
lidarPointCloudGeneratorGenerate lidar point cloud data for driving scenario

Mesh Creation

extendedObjectMeshMesh representation of extended object
translateTranslate mesh along coordinate axes
rotateRotate mesh about coordinate axes
scaleScale mesh in each dimension
applyTransformApply forward transformation to mesh vertices
joinJoin two object meshes
scaleToFitAuto-scale object mesh to match specified cuboid dimensions
showDisplay the mesh as a patch on the current axes

Prebuilt Meshes

driving.scenario.bicycleMeshMesh representation of bicycle in driving scenario
driving.scenario.carMeshMesh representation of car in driving scenario
driving.scenario.pedestrianMeshMesh representation of pedestrian in driving scenario
driving.scenario.truckMeshMesh representation of truck in driving scenario

Plotter Creation

birdsEyePlotPlot detections, tracks, and sensor coverages around vehicle
coverageAreaPlotterCoverage area plotter for bird's-eye plot
detectionPlotterDetection plotter for bird's-eye plot
trackPlotterTrack plotter for bird's-eye plot
laneBoundaryPlotterLane boundary plotter for bird's-eye plot
laneMarkingPlotterLane marking plotter for bird's-eye plot
meshPlotterMesh plotter for bird's-eye plot
pathPlotterPath plotter for bird's-eye plot
pointCloudPlotterPoint cloud plotter for bird's-eye plot
outlinePlotterOutline plotter for bird's-eye plot

Plotter Display

plotCoverageAreaDisplay sensor coverage area on bird's-eye plot
plotDetectionDisplay object detections on bird's-eye plot
plotLaneBoundaryDisplay lane boundaries on bird’s-eye plot
plotLaneMarkingDisplay lane markings on bird’s-eye plot
plotMeshDisplay object meshes on bird's-eye plot
plotOutlineDisplay object outlines on bird's-eye plot
plotPathDisplay actor paths on bird’s-eye plot
plotPointCloudDisplay generated point cloud on bird's-eye plot
plotTrackDisplay object tracks on bird's-eye plot

Plotter Utilities

findPlotterFind plotters associated with bird’s-eye plot
clearDataClear data from specific plotter of bird’s-eye plot
clearPlotterDataClear data from bird’s-eye plot


Create Driving Scenario Programmatically

Programmatically create ground truth driving scenarios for synthetic sensor data and tracking algorithms.

Define Road Layouts Programmatically

Programmatically create road junctions and combine these junctions to create more complicated road networks.

Create Actor and Vehicle Trajectories Programmatically

Programmatically create actor and vehicle trajectories for a driving scenario.

Create Driving Scenario Variations Programmatically

Programmatically create variations of a driving scenario that was built using the Driving Scenario Designer app.

Visualize Sensor Coverage, Detections, and Tracks

Configure and use a bird's-eye plot to display sensor coverage, detections, and tracking results around the ego vehicle.

Automate Control of Intelligent Vehicles by Using Stateflow Charts

Model a highway scenario with intelligent vehicles that are controlled by decision logic defined by a Stateflow® chart.

Featured Examples