a = 1000; % 长轴
b = 200; % 短轴
x0 = 100; % 中心点x坐标
y0 = 100; % 中心点y坐标
ellipse(a,b,x0,y0)
function ellipse(a,b,x0,y0)
Num=100000;
cicle=zeros(Num,2);
for i=1:Num
theta=-pi+i/Num*2*pi;
dOP=a*b/sqrt(a^2*sin(theta)^2+b^2*cos(theta)^2);
cicle(i,:)= dOP*[cos(theta) sin(theta)];
end
plot(cicle(:,1)+x0,cicle(:,2)+y0);
end
参考修改自:https://blog.csdn.net/weixin_41597703/article/details/103274408