- 积分
- 580
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2016-2-28
- 最后登录
- 1970-1-1
|
发表于 2016-2-28 23:53:29
|
显示全部楼层
楼主有无试试regionpatch
代码如下(x和y为边界数据):
function hc=regionpatch(varargin)
% patch the region outside the define region
% Usage: hc=regionpatch(|h,x,y,|color)
% h is axes handle. gca by default.
% color is the facecolor of out of region, white by default.
mv=0;temp=varargin{1};
if length(temp)==1&&ishandle(temp), h=temp;mv=mv+1;end
x=varargin{mv+1};y=varargin{mv+2};
if nargin>mv+2, c=varargin{mv+3};end
if ~exist('h','var'), h=gca;end
if ~exist('c','var'), c='w';end
axes(h);hold on;
range=axis;
x=x(:);y=y(:);
[xi,i]=max(x);
x=[x(1:i);range([2 2 1 1 2 2])';x(i:end)];
y=[y(1:i);y(i);range([4 4 3 3])';y(i);y(i:end)];
hc=patch(x,y,c);
set(hc,'linestyle','none','edgecolor','none'); |
|