I tried some functions with the best so far being
compnum = 2;
compos = [1,1;4,3];
complist = [3,1;4,3];
point1 = [compos(1,1)+complist(1,1)/2,compos(1,2)+complist(1,2)/2];
point2 = [compos(2,1)+complist(2,1)/2,compos(2,2)+complist(2,2)/2];
D = twopointdist(point1,point2)
xlim([0,10]),ylim([0,16])
for i = 1:compnum
% h(i) = rectangle('Position',[compos(i,1),compos(i,2),complist(i,1),complist(i,2)],...
% 'Curvature',[0,0],...
% 'LineWidth',2,'LineStyle','-')
h(i) = impositionrect(gca, [compos(i,1),compos(i,2),complist(i,1),complist(i,2)]);
daspect([1,1,1])
text(compos(i,1),compos(i,2),num2str(i))
text(compos(i,1),compos(i,2)+complist(i,2)/2,num2str(D))
end
But still i need to merge the text and somehow find a way to re-compute and re-display the distance each time i move one of them.