function regionhs(c,d,h1,h2)
% regionhs(c,d,h1,h2)
%
% plot horizontally simple region
%   c <= y <= d
%  h1 <= x <= h2
% where h1,h2 are symbolic expressions of y.
% 
% Example: circle of radius 1 and center (0,0)
%   syms y
%   h1 = -sqrt(1-y^2)
%   h2 = sqrt(1-y^2)
%   regionhs(-1,1,h1,h2)
%   axis equal; 

syms y
c = double(c); d = double(d);
h1 = sym(h1); h2 = sym(h2);

hs = ishold;
ezplot(h1,y,[c,d]); hold on         % left boundary of R
ezplot(h2,y,[c,d]);                 % right boundary of R
yv = linspace(c,d,25);              % use vector of 25 y-values from c to d
h1v = subs(h1,y,yv);                % corresponding h1-values
h2v = subs(h2,y,yv);                % corresponding h2-values
plot([h1v;h2v],[yv;yv],'r');        % draw horizontal lines in red

if hs==0
  hold off
end

