## Draw Shapes and Lines

When you specify the type of shape to draw, you must also specify it’s location on the image. The table shows the format for the points input for the different shapes.

### Rectangle

ShapePTS inputDrawn Shape
Single RectangleFour-element row vector
```[x y width height]``` where
• `x` and `y` are the one-based coordinates of the upper-left corner of the rectangle.

• `width` and `height` are the width, in pixels, and height, in pixels, of the rectangle. The values of `width` and `height` must be greater than 0. M Rectangles

M-by-4 matrix

`$\left[\begin{array}{cccc}{x}_{1}& {y}_{1}& widt{h}_{1}& heigh{t}_{1}\\ {x}_{2}& {y}_{2}& widt{h}_{2}& heigh{t}_{2}\\ ⋮& ⋮& ⋮& ⋮\\ {x}_{M}& {y}_{M}& widt{h}_{M}& heigh{t}_{M}\end{array}\right]$`

where each row of the matrix corresponds to a different rectangle and is of the same form as the vector for a single rectangle. ### Line and Polyline

You can draw one or more lines, and one or more polylines. A polyline contains a series of connected line segments.

ShapePTS inputDrawn Shape
Single LineFour-element row vector `[x1 y1 x2 y2]` where
• `x1` and `y1` are the coordinates of the beginning of the line.

• `x2` and `y2` are the coordinates of the end of the line. M Lines

M-by-4 matrix

`$\left[\begin{array}{cccc}{x}_{11}& {y}_{11}& {x}_{12}& {y}_{12}\\ {x}_{21}& {y}_{21}& {x}_{22}& {y}_{22}\\ ⋮& ⋮& ⋮& ⋮\\ {x}_{M1}& {y}_{M1}& {x}_{M2}& {y}_{M2}\end{array}\right]$`

where each row of the matrix corresponds to a different line and is of the same form as the vector for a single line. Single Polyline with (L-1) SegmentsVector of size 2L, where L is the number of vertices, with format, ```[x1, y1, x2, y2, ..., xL, yL]```.
• x1 and y1 are the coordinates of the beginning of the first line segment.

• x2 and y2 are the coordinates of the end of the first line segment and the beginning of the second line segment.

• xL and yL are the coordinates of the end of the (L-1)th line segment.

The polyline always contains (L-1) number of segments because the first and last vertex points do not connect. The block produces an error message when the number of rows is less than two or not a multiple of two. M Polylines with (L-1) Segments

2L-by-N matrix

`$\left[\begin{array}{ccccccc}{x}_{11}& {y}_{11}& {x}_{12}& {y}_{12}& \cdots & {x}_{1L}& {y}_{1L}\\ {x}_{21}& {y}_{21}& {x}_{22}& {y}_{22}& \cdots & {x}_{2L}& {y}_{2L}\\ ⋮& ⋮& ⋮& ⋮& \ddots & ⋮& ⋮\\ {x}_{M1}& {y}_{M1}& {x}_{M2}& {y}_{M2}& \cdots & {x}_{ML}& {y}_{ML}\end{array}\right]$`

where each row of the matrix corresponds to a different polyline and is of the same form as the vector for a single polyline. When you require one polyline to contain less than (L–1) number of segments, fill the matrix by repeating the coordinates of the last vertex.

The block produces an error message if the number of rows is less than two or not a multiple of two. ### Polygon

You can draw one or more polygons.

ShapePTS inputDrawn Shape
Single Polygon with L line segmentsRow vector of size 2L, where L is the number of vertices, with format, ```[x1 y1 x2 y2 ... xL yL]``` where
• x1 and y1 are the coordinates of the beginning of the first line segment.

• x2 and y2 are the coordinates of the end of the first line segment and the beginning of the second line segment.

• xL and yL are the coordinates of the end of the (L-1)th line segment and the beginning of the Lth line segment.

The block connects `[x1 y1]` to `[xL yL]` to complete the polygon. The block produces an error if the number of rows is negative or not a multiple of two. M Polygons with the largest number of line segments in any line being L

M-by-2L matrix

`$\left[\begin{array}{ccccccc}{x}_{11}& {y}_{11}& {x}_{12}& {y}_{12}& \cdots & {x}_{1L}& {y}_{1L}\\ {x}_{21}& {y}_{21}& {x}_{22}& {y}_{22}& \cdots & {x}_{2L}& {y}_{2L}\\ ⋮& ⋮& ⋮& ⋮& \ddots & ⋮& ⋮\\ {x}_{M1}& {y}_{M1}& {x}_{M2}& {y}_{M2}& \cdots & {x}_{ML}& {y}_{ML}\end{array}\right]$`

where each row of the matrix corresponds to a different polygon and is of the same form as the vector for a single polygon. If some polygons are shorter than others, repeat the ending coordinates to fill the polygon matrix.

The block produces an error message if the number of rows is less than two or is not a multiple of two. ### Circle

You can draw one or more circles.

ShapePTS inputDrawn Shape
Single CircleThree-element row vector
`[x y radius]` where
• `x` and `y` are coordinates for the center of the circle.

• `radius` is the radius of the circle, which must be greater than 0. M Circles

M-by-3 matrix

`$\left[\begin{array}{ccc}{x}_{1}& {y}_{1}& radiu{s}_{1}\\ {x}_{2}& {y}_{2}& radiu{s}_{2}\\ ⋮& ⋮& ⋮\\ {x}_{M}& {y}_{M}& radiu{s}_{M}\end{array}\right]$`

where each row of the matrix corresponds to a different circle and is of the same form as the vector for a single circle. 