-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotboxes.m
More file actions
38 lines (33 loc) · 813 Bytes
/
plotboxes.m
File metadata and controls
38 lines (33 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function plotboxes(xs,ys,color,edgecolor)
% function plotboxes(xs,ys,color)
%
% xs and ys are n-by-2. must have same n, or one must have n=1.
% color is optional (default = light gray)
% edgecolor is optional (default = none)
% deal with inputs
if nargin < 3
color = [.9 .9 .9];
end
if nargin < 4
edgecolor = 'none';
end
if size(xs,1)>size(ys,1)
if size(ys,1)~=1
error('ys must be size of xs or 1x2')
else
ys = repmat(ys,size(xs,1),1);
end
elseif size(ys,1)>size(xs,1)
if size(xs,1)~=1
error('xs must be size of ys or 1x2')
else
xs = repmat(xs,size(ys,1),1);
end
end
% plot
for iBox = 1:size(xs,1)
x = xs(iBox,:);
y = ys(iBox,:);
fill([x(1) x(2) x(2) x(1)], [y(1) y(1) y(2) y(2)], ...
color, 'EdgeColor', edgecolor)
end