MATLAB: Plotting concentric circles using contour

plotting

I'm trying to plot a few concentric circles with the following codes, but what I get is an ellipse, i don't know why:
[x,y] = meshgrid(-3:0.1:3,-3:0.1:3);
z = x.^2+y.^2;
contour(x,y,z)

Best Answer

Use the axis function, specifically either:
axis('equal') % Function Expression
or:
axis equal % Command Expression
.