回复: for循环做一个同心圆环图像时的问题
a=input('请输入圆心横坐标(例如 -2):');
b=input('请输入圆心纵坐标(例如 3):');
for n=1:1:10
t=linspace(-pi,pi);
x=sin(t)*sqrt(0.02*n)+a;
y=cos(t)*sqrt(0.02*n)+b;
plot(x,y)
hold on
axis equal
end
for n=1:2:9
t=linspace(-pi,pi);
x0=sin(t)*sqrt(0.02*n)+a;
x1=sin(t)*sqrt(0.02*(n+1))+a;
t=x0:0.01:x1;
y0=cos(t)*sqrt(0.02*n)+b;
y1=cos(t)*sqrt(0.02*(n+1))+a;
s=y0:0.01:y1;
plot(t,s,'b')
hold on
end
这样应该可以了,你把那个对应于每个圆环中的点拿出来,然后绘成黑色的点图就可以了。
__________________
坚持就是胜利,努力就有奇迹。
|