Main Content

Use theaterPlot to Visualize Radar Scenario

This example shows how to use theaterPlot to visualize various aspects of a radar scenario.


theaterPlot is an efficient tool for visualizing various aspects of a radar scenario. It is composed of a primary object, which hosts the plotting environment based on a parent axes, and plotters to plot the desired aspects of features from the radar scenario.

This figure shows a structural representation of a theaterPlot object.

The Parent property specifies the axes on which the theater plot is enabled. You can specify the parent axes of a theater plot during object creation. If you do not specify a parent axes, theaterPlot creates a new figure and uses the current axes of the created figure as its Parent property. You can also set the axes limits of the parent axes using the XLimits, YLimits, and Zlimits properties by using name-value pair arguments during object creation. Set the units of measurement for each axes using the AxesUnits property.

The Plotters property holds plotters that you added to the theaterPlot object.

You can specify visual elements and effects for each plotter during the creation of the plotter. Each plotter is also paired with a theaterPlot object function, which you need to call to plot the results. For example, a coveragePlotter is paired with a plotCoverage object function that shows the sensor coverage.

This example showcases a few plotters for visualizing a radar scenario. theaterPlot can work efficiently with a radarScenario even though you do not necessarily need a radarScenario to use the theaterPlot object.

Create theaterPlot and radarScenario Objects

Create a radarScenario object and a theaterPlot object.

simulationDuration = 100;
scene = radarScenario('StopTime',simulationDuration);
tp = theaterPlot('XLimits',[-250 250],'YLimits',[-250 250],'ZLimits',[0 120]);
view(3);grid on;

Create a Trajectory Plotter and a Platform Plotter for a Target

Create a waypoint trajectory for a target platform.

timeOfArrival = [0  simulationDuration];
waypoints = [100 -100 10; 100 100 80];
trajectory = waypointTrajectory(waypoints,timeOfArrival);

Add a cuboid target platform that follows the specified trajectory. First add a target platform to the radar scenario.

target = platform(scene,'Trajectory',trajectory,'Dimensions', ...
    struct('Length',35,'Width',15,'Height',5.5,'OriginOffset',[0 0 0]));

Then add a trajectoryPlotter object to the theaterPlot object, and use the plotTrajectory function to plot the waypoint trajectory.

trajPlotter = trajectoryPlotter(tp,'DisplayName','Trajectory','Color','k','LineWidth',1.2);

Tip You can plot multiple same-type features (platforms, trajectories, orientations, coverages, detections, or tracks) together using one plotter. For example, you can plot multiple trajectories together by specifying a cell array of waypoints as the second argument of the plotTrajectory function. See the syntax description of plotTrajectory for more details.

Define a plotter for the target platform.

targetPlotter = platformPlotter(tp,'DisplayName','Target', ...
plotPlatform(targetPlotter,target.Position, ...

You can add graphical objects other than the plotter objects on the theaterPlot by directly plotting on the parent axes of the theaterPlot object. Put a circle marker at the origin.

hold on

Create a Platform with a Mounted radar Sensor

Add a tower platform to the scenario.

tower = platform(scene,'Position',[-100,0,0],'Dimensions', ...
    struct('Length',5,'Width',5,'Height',30,'OriginOffset',[0 0 -15]));

Display the tower using a platform plotter.

towerPlotter = platformPlotter(tp,'DisplayName','Tower','Marker','s','MarkerSize',2);

Mount a monostatic radar to the top of the tower.

radar = radarDataGenerator(1,'DetectionMode','Monostatic', ...
    'UpdateRate',5, ...
    'MountingLocation',[0, 0, 30], ...
    'FieldOfView',[4, 30],...
    'MechanicalAzimuthLimits',[-60 60], ...
    'MechanicalElevationLimits',[0 0], ...
    'HasElevation',true, ...
    'RangeResolution',200, ...
    'AzimuthResolution',20, ...
tower.Sensors = radar;

Add a coveragePlotter and plot the coverage and initial beam for the monostatic radar. When plotting the coverage, the plotCoverage object function requires a second argument that specifies the configuration of the sensor coverage. Obtain the configuration by using the coverageConfig function on the radar scenario scene.

radarPlotter = coveragePlotter(tp,'Color','b','DisplayName','radar beam');

Create a detection plotter to plot the detections that the radar generates.

detPlotter = detectionPlotter(tp,'DisplayName','Detection','MarkerFaceColor','r','MarkerSize',4);

Run the scenario and update the theater plot

Iterate through the radar scenario and generate radar detections. Plot the platform, radar coverage, and detections.

rng(2019) % for repeatable results
while advance(scene)
    % Plot target.
    plotPlatform(targetPlotter,target.Position, ...

    % Plot sensor coverage.

    % Extract target pose from the view of the tower and use the extracted
    % pose to generate detections.
    poseInTower = targetPoses(tower);
    [detections, numDets] = radar(poseInTower,scene.SimulationTime);
    detPos = zeros(numDets,3);
    detNoise = zeros(3,3,numDets);

    % Obtain detection pose relative to the scenario frame. Also, obtain
    % the covariance of the detection.
    for i=1:numDets
        a = detections;
        detPos(i,:) = tower.Trajectory.Position + detections{i}.Measurement';
        detNoise(:,:,i) = detections{i}.MeasurementNoise;

    % Plot any generated detections with the covariance ellipses.
    if ~isempty(detPos)

Figure contains an axes. The axes contains 7 objects of type line, patch. These objects represent Trajectory, Target, Tower, radar beam, Detection.

You can zoom in on the detection in the figure to visualize the plotted covariance ellipses of the generated detections.


In this example, you learned about the organization of a theaterPlot object. You also learned how to visualize a simple radar scenario using the theaterPlot object.