To get the bounding box with sides parallel to the XY-axes you simply need to find the min/max of all the x and y koordiantes:
minx = min(xcoords);
maxx = max(xcoords);
miny = min(ycoords);
maxy = max(ycoords);
The bounding box has corners in (minx, miny), (minx, maxy), (maxx, maxy), (maxx, miny).