%% Bounding Box of Polygon
% Create a polygon containing two solid regions, and compute the lower and upper x and y bounds that enclose it.

x1 = [0 1 2];
y1 = [0 1 0];
x2 = [2 3 4];
y2 = [1 2 1];
polyin = polyshape({x1,x2},{y1,y2});
[xlim,ylim] = boundingbox(polyin);
plot(polyin)
hold on
plot(xlim,ylim,'r*',xlim,fliplr(ylim),'r*')

% Copyright 2012 The MathWorks, Inc.