Assuming the rectangles overlap, the part for the plotting could be done like this:
if (A(1)<=B(1))
intersection(1)=B(1);
intersection(3)=A(1)+A(3)-B(1);
else
intersection(1)=A(1);
intersection(3)=B(1)+B(3)-A(1);
end
if (A(2)<=B(2))
intersection(2)=B(2);
intersection(4)=A(2)+A(4)-B(2);
else
intersection(2)=A(2);
intersection(4)=B(2)+B(4)-A(2);
end
intersectionPlot=rectangle('Position', intersection);
set(intersectionPlot, 'FaceColor', 'r'); % r stands for red, you can choose any other color