This function creates a set of polygons characterized by their vertices and places them by their reference onto a given set of 2D coordinates in a GDSII file. The connection between polygon type and position is accomplished through a map. In the GDS file the polygon references are united in a single cell which is situated on a given layer.
Syntax 
Description 

gdsmultipoly(f, cell_name, layer, polygon_vertices, x, y, map); 
Adds a cell with multiple types of polygons to a layer at specific positions. The polygon types corresponding to the different positions. 
Parameter 
Type 
Description 

f 
string 
A file handle that was previously opened with gdsopen. 
cell_name 
string 
Name of the cell. 
layer 
string or number 

polygon_vertices 
cell 
Cell of polygon 2D vertex matrices. The number of cell entries corresponds to the number of different types of polygons. For a polygon with n vertices, the vertex matrix has the dimension nx2 where the first column represents x coordinate and the second column represents y coordinate, e.g., [x1,y1; x2,y2;…; xn,yn]. 
x 
matrix 
x positions of the polygons 
y 
matrix 
y positions of the polygons 
map 
matrix 
Matrix of nonnegative integers mapping the different polygon types to the given coordinates (x, y) where each entry corresponds to a polygon in the polygon_vertices cells in the order of occurrence e.g., for polygon vertices {p1, p2, p3} the number '2' corresponds to polygon p2. The map can either be a 1darray where the length corresponds to the length of x and y. Or it can be a 2darray of dimension K x L where K==length( x ) and L==length( y ). The special value "0" indicates that there is no structure at this position. 
Example
The following script command creates the polygons using an 1Darray map where length(map) = length(x) = length(y).
unit = 1e6;
# Rhombus (identifier 1)
x1 = [unit; 0; unit; 0];
y1 = [0; unit; 0; unit];
v1 = [x1, y1];
# Square (identifier 2)
x2 = [unit; unit; unit; unit];
y2 = [unit; unit; unit; unit];
v2 = [x2, y2];
# Hexagon (identifier 3)
x3 = [unit; 0.5*unit; 0.5*unit; unit; 0.5*unit; 0.5*unit];
y3 = [0; unit; unit; 0; unit; unit];
v3 = [x3, y3];
polygons = {v1, v2, v3};
x = [0, 4.4*unit, 6.6*unit, 8.8*unit];
y = [0, unit, unit, 0];
# Map containing polygon identifiers:
map = [1, 2, 3, 2];
layer = 1;
f = gdsopen('polygons.gds');
gdsaddmultipoly(f, 'POLYGONS', layer, polygons, x, y, map);
gdsclose(f);
Alternatively, one can use a 2Darray map where length(map) = length(x)*length(y) for the same result.
x = linspace(0, 10*unit, 5);
y = linspace(2*unit, 0, 3);
# Map containing polygon identifiers:
map = [0, 0, 2, 0, 0;
1, 0, 0, 0, 2;
0, 0, 0, 3, 0];