format
v=5;
R=0.5;
c1=1;
m=1;
for b=0:0.1:(pi/2)
r1(m)=(((c1/(v*sin(b)))^2+4*(R^2))^0.5+c1/(v*sin(b)))/2;
x1(m)=(r1(m)/(1+(tan(b))^2))^0.5;
y1(m)=tan(b)*(r1(m)/(1+(tan(b))^2))^0.5;
m=m+1;
end
c2=3;
m=1;
for b=0:0.1:(pi/2)
r2(m)=(((c2/(v*sin(b)))^2+4*R^2)^0.5+c2/(v*sin(b)))/2;
x2(m)=(r2(m)/(1+(tan(b))^2))^0.5;
y2(m)=tan(b)*(r2(m)/(1+(tan(b))^2))^0.5;
m=m+1;
end
c3=5;
m=1;
for b=0:0.1:(pi/2)
r3(m)=(((c3/(v*sin(b)))^2+4*R^2)^0.5+c3/(v*sin(b)))/2;
x3(m)=(r3(m)/(1+(tan(b))^2))^0.5;
y3(m)=tan(b)*(r3(m)/(1+(tan(b))^2))^0.5;
m=m+1;
end
c4=7;
m=1;
for b=0:0.1:(pi/2)
r4(m)=(((c4/(v*sin(b)))^2+4*R^2)^0.5+c4/(v*sin(b)))/2;
x4(m)=(r4(m)/(1+(tan(b))^2))^0.5;
y4(m)=tan(b)*(r4(m)/(1+(tan(b))^2))^0.5;
m=m+1;
end
m=m+1;
for b=0:0.1:2*pi
circlex(m)=R*sin(b);
circley(m)=R*cos(b);
m=m+1;
end
plot(x1,y1,-x1,y1,x1,-y1,-x1,-y1,x2,y2,-x2,y2,x2,-y2,-x2,-y2,x3,y3,-x3,y3,x3,-y3,-x3,-y3,x4,y4,-x4,y4,x4,-y4,-x4,-y4,circlex,circley)
axis ('equal','auto')
title('理想流体绕过圆柱流动的流线分布图')
gtext('圆柱表面')
呵呵,这是改过的,那几个没有错啊
只是觉得for语句太多了,可以分段将数组中元素取出来画线吗? |