who can i plot streamlines on a disk

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?

 Respuesta aceptada

darova
darova el 28 de Mayo de 2020
  • 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 comentario

diala hawat
diala hawat el 29 de Mayo de 2020
thank you the idea of removing the corners works.

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Versión

R2017a

Preguntada:

el 28 de Mayo de 2020

Comentada:

el 29 de Mayo de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by