function new = combineldb (ldb1,ldb2) new = 0; r1 = readldb(ldb1); r2 = readldb(ldb2); %remove identical points [t1a.x,t1a.y] = removeidentical(r1.x,r1.y); mv = 1; r1a.x = t1a.x(mv+1:end) r1a.x = [r1a.x;t1a.x(1:mv)]; r1a.y = t1a.y(mv+1:end) r1a.y = [r1a.y;t1a.y(1)]; [t2a.x,t2a.y] = removeidentical(r2.x,r2.y); r2a = t2a; Clockwise1 = polyIsClockwise(r1a.x,r1a.y); %!!!clockwise is tegen de klok in if Clockwise1 r1a.x = flipud(r1a.x); r1a.y = flipud(r1a.y); end Clockwise2 = polyIsClockwise(r2a.x,r2a.y); if Clockwise2 r2a.x = flipud(r2a.x); r2a.y = flipud(r2a.y); end mm = ones(length(r1a.x),length(r2a.x),1)* NaN; for n = 1 : length(r1a.x) for m = 1 : length(r2a.x) mm(n,m) = sqrt((r1a.x(n)-r2a.x(m))^2 +(r1a.y(n)-r2a.y(m))^2); end end [in,im] = find (mm == 0); new.x = []; new.y = []; teller = 0; for n = 1 : in(end) teller = teller + 1; new.x(teller) = r1a.x(n); new.y(teller) = r1a.y(n); end for n = im(end) : length(r2a.x) teller = teller + 1; new.x(teller) = r2a.x(n); new.y(teller) = r2a.y(n); end for n = 1 : im(1) teller = teller + 1; new.x(teller) = r2a.x(n); new.y(teller) = r2a.y(n); end for n = in(1) : length(r1a.x) teller = teller + 1; new.x(teller) = r1a.x(n); new.y(teller) = r1a.y(n); end if new.x(1) ~= new.x(end) && new.y(1) ~= new.y(end) teller = teller + 1; new.x(teller) = new.x(1); new.y(teller) = new.y(1); end plot(new.x,new.y,'-xb'); ii=1; end