Matlab 查找流线并将其绘制在图形上
我试图绘制以下流程的流线图: 我们正在用一条稀疏线绘制停滞点,但不知何故流线刚好越过它。。。 我们不能使用stream函数。你知道怎么了吗 不知何故,绘图不正确…以下是我的matlab代码:Matlab 查找流线并将其绘制在图形上,matlab,Matlab,我试图绘制以下流程的流线图: 我们正在用一条稀疏线绘制停滞点,但不知何故流线刚好越过它。。。 我们不能使用stream函数。你知道怎么了吗 不知何故,绘图不正确…以下是我的matlab代码: %% constant parameters a=1; U=100; T=3*pi*a*U; %% plot the stagnation points syms z k=100./z^2 - 1i*3./(2*z) - 100==0; %diff(w)==0 stagpoint=solve(k
%% constant parameters
a=1;
U=100;
T=3*pi*a*U;
%% plot the stagnation points
syms z
k=100./z^2 - 1i*3./(2*z) - 100==0; %diff(w)==0
stagpoint=solve(k,z); %get the points
plot(stagpoint,'MarkerFaceColor','g');
%% plot the the sparatrix line
[x,y]=meshgrid([-7:0.1:7],[-2:0.1:2]);
z=x+1i*y;
w1=-100*(z+1./z)-1i*log(z).*3*pi*100./(2*pi);
psi=imag(w1);
limit=sqrt(x.^2+y.^2);
x((limit<0.99))=NaN;
y((limit<0.99))=NaN;
contour(x,y,psi,'k');
xlabel('Re');
ylabel('Im');
title('streamline for question4(a)');
axis([-5 5 -5 5])
daspect([1 1 1]);
hold on
%% plot streamline
RK4_4A(z);
%% plot the surface of the cylinder
angle=[0:0.1:360];
x=cosd(angle); %x component of the cylinder
y=sind(angle); %y component of the cylinder
plot(x,y);
hold on
fill(x,y,'r');
在函数RK4_4A(zn)
中,您接收数据zn
,但稍后您将zn
替换为x+1i*y
。你为什么这么做?
function RK4_4A(zn)
h=0.001;
x=5;
y=[-5:0.5:5];
zn=x+1i*y;
for j=1:length(y)
z(1)=zn(j);
t=0:h:2;
for i=1:length(t)-1
k1 = ffunc(z(i));
k2 = ffunc(z(i)+h/2*k1);
k3 = ffunc(z(i)+h/2*k2);
k4 = ffunc(z(i)+h*k3);
z(i+1) = z(i) + h*(1/6*k1+1/3*k2...
+1/3*k3+1/6*k4);
end
plot(real(z),imag(z),'b');
hold on
end
function s=ffunc(z)
s = 100./z^2 - 1i*3./(2*z) - 100;
s=conj(s);
end
end