MATLAB: Get drawable axis position after axis equal

axisfigureposition;

Say I run this simple test:
figure;
axis;
axis equal;
Then you resize it a little, and run this
disp(gca.Position)
The answer will always be
ans =
0.1300 0.1100 0.7750 0.8150
which means the Position array will always stay the same, but the drawable (white) area of the axes object will always be resized to fit as much as possible inside that Position array.
The thing is that I want the actual position of the upper-right corner of the drawable area axes object. In this image, I want the position of the green point, not the red point to which I could arrive simply using Position.

Best Answer

See https://www.mathworks.com/matlabcentral/answers/5882-getting-the-axis-position-correctly : The properties TightInset and PlotBoxAspectRatio matter. Before you can interpret them, the axes' units must be set to pixels:
figure
h = axes
axis equal
pause(5); % Change the figure size
h.Units = 'pixels';
disp(h.TightInset)
disp(h.PlotBoxAspectRatio)
disp(h.Position)
h.Units = normalized;
This should help you to find the solution. Unfortunately I cannot provide a working code yet.