Main Content


Plot parking space

Since R2021b



plot(space) plots a bird's-eye view of a parking space. Use this plot to examine the dimensions, angle, color, and type of a parking space before adding it to a parking lot.


plot(space,Origin=visibility) sets the visibility of the parking space origin to "on" or "off".


collapse all

Explore the various parking lots that you can create by using predefined layouts as well as the options for configuring those layouts.

Define the parking space used to populate the parking lot. Modify the width, length, or angle of the space and the width and strength of its lane markings. Plot the parking space.

width = 2.6; % m
length = 5.5; % m
angle = 90; % deg
markingWidth = 0.15;
markingStrength = 1;

space = parkingSpace(Width=width, ...
                    Length=length, ...
                    Angle=angle, ...
                    MarkingWidth=markingWidth, ...

Create a driving scenario containing a 50-by-50 meter parking lot. Specify a predefined parking lot layout and a minimum driving lane width. The generated parking lot fills with as many parking spaces that fit the layout as possible given the minimum driving lane width constraint. Modify the parking space, layout type, and driving lane width, and observe the effects on the parking lot. For example:

  • As you increase the size of the parking space or the minimum driving lane width, the number of parking grids that fit in the middle of the parking lot decreases.

  • If you select the HorizontalWithEdges or VerticalWithEdges layout, one edge has fewer spaces than the others. This edge contains a driving lane of width DrivingLaneWidth that enables vehicles to enter the parking lot.

scenario = drivingScenario;
vertices = [0 0; 50 0; 50 -50; 0 -50];
parkingLayout = "Vertical";
drivingLaneWidth = 2.6; % m

parkingLot(scenario,vertices, ...
    ParkingSpace=space, ...
    ParkingLayout=parkingLayout, ...


Create a parking lot that contains a mixture of parking spaces, no-parking areas, and accessible spaces.

Define the parking space to use in the parking lot. Use the default settings. Plot the space.

space = parkingSpace;

Define the no-parking areas to use in the parking lot. Specify a color of white and a width that is one meter less than the width of the default parking space. Plot the space.

noSpace = parkingSpace(Type="NoParking",Width=(space.Width - 1),MarkingColor="White");

Define the accessible parking space to use in the parking lot. Specify a width that is one meter more than the width of the default parking space. Plot the space.

accessibleSpace = parkingSpace(Type="Accessible",Width=(space.Width + 1));

Create a driving scenario containing a parking lot with a nonrectangular layout. Plot the parking lot and display the edge numbers along which you can add parking spaces.

scenario = drivingScenario;
vertices = [0 0; 32 -10.5; 32 -50.5; 25 -57.5; 0 -57.5];
lot = parkingLot(scenario,vertices);

Insert default parking spaces along the first three edges of the parking lot. To avoid overlapping parking spaces, make these adjustments to the insertions:

  • Along edge 1, insert only 10 spaces.

  • Along edge 2, offset the spaces by 5 meters from the first vertex of the edge.

  • Along edge 3, offset the spaces by 3 meters from the first vertex of the edge.

numSpaces = 10;

In the center of the parking lot, insert a 2-by-10 grid of parking spaces containing 8 columns of default spaces, 1 column of no-parking areas, and 1 column of accessible spaces.

insertParkingSpaces(lot,[space noSpace accessibleSpace],[8 1 1],Position=[12 -18],Rows=2)

Input Arguments

collapse all

Parking space, specified as a parkingSpace object.

Visibility of parking space origin, specified as "on" or "off". The origin is located on the upper-left corner of the parking space.

Data Types: char | string

Version History

Introduced in R2021b