Quantcast
Channel: MATLAB Central Newsreader Recent Posts
Viewing all articles
Browse latest Browse all 19628

Re: Merge line segments

$
0
0
% Try this:

function l = merge_lines(l1, l2)
l = [l1; l2];
p = (l*l');
d = diag(p);
d2 = bsxfun(@plus,d,d')-2*p;
[~, k] = max(d2(:));
l = l([mod(k-1,4)+1 ceil(k/4)],:);
end

% Bruno

Viewing all articles
Browse latest Browse all 19628

Trending Articles