MATLAB: Does an ellipse rotated at an angle appear incorrectly with the ‘Stretch to fit’ aspect ratio

MATLAB

When I execute the following commands:
hold('on');
xlimits(1) = 0;
xlimits(2) = 30;
XLim(xlimits);
x = [1:10]; y = [5,5,5,5,5,5,5,5,5,5];
plot (x,y);
x = [5,5,5,5,5,5,5,5,5,5]; y = [1:10];
plot (x,y);
midX = 5;
midY = 5;
b = 1;
a = 2;
lowX = midX - b;
highX = midX + b;
j = 1;
% get top half of ellipse
xin = lowX;
littlebit = (highX - lowX) / 20; % get 20 points
while (xin <= highX)
x(j) = xin;
% equation of an ellipse
y(j) = midY + (a/b)*sqrt((b*b)-(xin-midX)*(xin-midX));
j = j + 1;
xin = xin + littlebit;
end
% get the bottom half of the ellipse
xin = highX;
while (xin >= lowX)
x(j) = xin;
y(j) = midY - (a/b)*sqrt((b*b)-(xin-midX)*(xin-midX));
j = j + 1;
xin = xin - littlebit;
end
% be sure to close the ellipse
x(j) = x(1);
y(j) = y(1);
h = plot(x,y,'Color','b');
zdir = [0 0 1];
center = [midX midY 0];
rotate(h,zdir,(180 + 45),center);
The ellipse appears incorrectly.

Best Answer

To display real-world objects in correct proportions, you need to set the data aspect ratio to [1 1 1] as shown below:
daspect([1 1 1]);