


FILLSEG Fills polygon line segments separated by [nan nan] (eg. Coastline data)
Usage: [h]=fillseg(x,c1,c2);
Inputs: x = two column matrix with x and y values, where
line segments are separated by [nan nan].
c1 = color for polygon fill ([r g b])
c2 = edgecolor for polygon ([r g b])
If c1 and c2 can be three column matrices, the first row is used to
fill the first segment, the second row is used to fill the second segment, etc.
Rich Signell (rsignell@usgs.gov)

0001 function [h]=fillseg(X,c1,c2); 0002 % FILLSEG Fills polygon line segments separated by [nan nan] (eg. Coastline data) 0003 % 0004 % Usage: [h]=fillseg(x,c1,c2); 0005 % 0006 % Inputs: x = two column matrix with x and y values, where 0007 % line segments are separated by [nan nan]. 0008 % c1 = color for polygon fill ([r g b]) 0009 % c2 = edgecolor for polygon ([r g b]) 0010 % 0011 % If c1 and c2 can be three column matrices, the first row is used to 0012 % fill the first segment, the second row is used to fill the second segment, etc. 0013 % 0014 % Rich Signell (rsignell@usgs.gov) 0015 % 0016 ii=find(isnan(X(:,1))); 0017 nseg=length(ii)-1; 0018 if(nseg>0), 0019 % fill out matrix c1 and c2 0020 if(length(c1(:))==3), 0021 c1=ones(nseg,1)*c1; 0022 c2=ones(nseg,1)*c2; 0023 elseif(length(c1(:))~=(3*nseg)), 0024 [m,n]=size(c1); 0025 clast=c1(m,:); 0026 c=clast(ones(nseg,1),:); 0027 c(1:m,:)=c1(1:m,:); 0028 c1=c; 0029 [m,n]=size(c2); 0030 clast=c2(m,:); 0031 c=clast(ones(nseg,1),:); 0032 c(1:m,:)=c2(1:m,:); 0033 c2=c; 0034 end 0035 for iseg=1:nseg; 0036 i1=ii(iseg)+1; 0037 i2=ii(iseg+1)-1; 0038 ind=i1:i2; 0039 h(iseg)=patch(X(ind,1),X(ind,2),c1(iseg,:));... 0040 set(h(iseg),'edgecolor',c2(iseg,:)); 0041 end 0042 end