who can i plot streamlines on a disk

조회 수: 2 (최근 30일)
diala hawat
diala hawat 2020년 5월 28일
댓글: diala hawat 2020년 5월 29일
i was trying to plot the streamlines on a disk so I creat a cirluar mesh grid as follows :
omega = [0:pi/50:pi];
R = [1:0.08:5];
[ThetaG,RG] = meshgrid(omega,R);
X = RG.*cos(ThetaG);
Y = RG.*sin(ThetaG);
Then i define the gradiend of a potential function U,V .
and creat the starting points
theta=0:pi/48:2*pi; % THIS MEANS 48 GRADIENT LINES FROM EACH point
sx=0.01*cos(theta);sy=0.01*sin(theta); %STARTING POINTS FOR GRADIENT FLOW ARE EQUISPACED POINTS AT DISTACE 0.1 FROM EACH ZERO.
and try to plot the stream lines as follows:
figure; hold on;
axis square on;
for k=1:p
h=streamline(X,Y,Dx,Dy,real(st(k))+sx,imag(st(k))+sy);
set(h,'Color', rand(3,1),'Linewidth',0.01);
plot(real(st(k)),imag(st(k)),'k*');
drawnow();
pause(0.1);
set(gca, 'fontsize',10);
end
but i get the error :
" Error using griddedInterpolant ,Interpolation requires at least two sample points in each dimension. " + ...
"Error in interp1 (line 149) ," + ...
"F = griddedInterpolant(X,V,method);" + ...
"Error in stream2 (line 63) syi=interp1(yy(:),1:szu(1),sy(k)); " + ...
"Error in streamline (line 62) ;" + ...
"verts = stream2(x,y,u,v,sx,sy,options);
and i don't know why !!! if i take [X,Y]=meshgrid(-6:0.005:6); instead of the circular meshgrid i didn't get any error.
How can i resolve this problem and plot the streamline on a disk?

채택된 답변

darova
darova 2020년 5월 28일
  • i don't know why !!! if i take [X,Y]=meshgrid(-6:0.005:6); instead of the circular meshgrid i didn't get any error.
Probably because of the mesh. streamline wants rectangular one
You can remove corners
[X,Y] = meshgrid(-5:0.2:5);
R = hypot(X,Y);
Z2 = sin(2*R)./R;
Z2(R>5) = nan;
[U2,V2] = gradient(Z2);
cla
surf(X,Y,Z2,'facecolor','none')
% streamline(X1,Y1,U1,V1,X1(:,1),Y1(:,1))
streamline(X,Y,U2,V2,X(:,15),Y(:,15))
axis vis3d
  댓글 수: 1
diala hawat
diala hawat 2020년 5월 29일
thank you the idea of removing the corners works.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by