function haxx=mergeaxes(hax)
% function haxx=mergeaxes(hax)
% merge axes and return the new handle

% F. Felici TU/e Sep 2012

for iax = 1:numel(hax)
    pp=get(hax(iax),'position');
    lef(iax) = pp(1);
    bot(iax) = pp(2);
    wid(iax) = pp(3);
    hig(iax) = pp(4);
end

rig = lef + wid;
top = bot + hig;

rr=max(rig);
ll=min(lef);
bb=min(bot);
tt=max(top);

posnew = [ll,bb,rr-ll,tt-bb];
haxx = axes('position',posnew);

delete(hax)

return
