rectPos = [1 2 5 6]; %[left, bottom, width, height];
interconnections(repmat(cumsum(rectPos([1,3])),2,1), repmat(cumsum(rectPos([2,4])),2,1)', true);
% This will also draw the rectangle
Alternatively,
rectPos = [1 2 5 6]; %[left, bottom, width, height];
rectangle('Position',rectPos);
hold on
plot(cumsum(rectPos([1,3])), [cumsum(rectPos([2,4]));fliplr(cumsum(rectPos([2,4])))], '-k')