Plot a rectangular/square box around a set of random points
Given a random set of points:
x=rand(1,100)*5;
y=rand(1,100)*5;
scatter(x,y,20,’blue’,’filled’)
xlim([-1 6])
ylim([-1 6])
how can I draw a rectangle that wraps that set of points, and such that the following conditions are fulfilled?
(1) the upper edge and the lower edge of the rectangle are placed at the lowest and highest y-coordinates of the set of points, i.e. at
yl = [min(y) max(y)];
(2) the left and the right edges are placed at the leftmost and rightmost x-coordinates of the set of points, i.e.
xl = [min(x) max(x)];
Visually, my desired output would be the following one:Given a random set of points:
x=rand(1,100)*5;
y=rand(1,100)*5;
scatter(x,y,20,’blue’,’filled’)
xlim([-1 6])
ylim([-1 6])
how can I draw a rectangle that wraps that set of points, and such that the following conditions are fulfilled?
(1) the upper edge and the lower edge of the rectangle are placed at the lowest and highest y-coordinates of the set of points, i.e. at
yl = [min(y) max(y)];
(2) the left and the right edges are placed at the leftmost and rightmost x-coordinates of the set of points, i.e.
xl = [min(x) max(x)];
Visually, my desired output would be the following one: Given a random set of points:
x=rand(1,100)*5;
y=rand(1,100)*5;
scatter(x,y,20,’blue’,’filled’)
xlim([-1 6])
ylim([-1 6])
how can I draw a rectangle that wraps that set of points, and such that the following conditions are fulfilled?
(1) the upper edge and the lower edge of the rectangle are placed at the lowest and highest y-coordinates of the set of points, i.e. at
yl = [min(y) max(y)];
(2) the left and the right edges are placed at the leftmost and rightmost x-coordinates of the set of points, i.e.
xl = [min(x) max(x)];
Visually, my desired output would be the following one: rectangle, sqaure, plot, points, wrap MATLAB Answers — New Questions