rectPos = [1 2 5 6];
interconnections(repmat(cumsum(rectPos([1,3])),2,1), repmat(cumsum(rectPos([2,4])),2,1)', true);
Alternatively,
rectPos = [1 2 5 6];
rectangle('Position',rectPos);
hold on
plot(cumsum(rectPos([1,3])), [cumsum(rectPos([2,4]));fliplr(cumsum(rectPos([2,4])))], '-k')
Best Answer