![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/173019/image.png)
Does anyone know why not all of my streamlines complete themselves?
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ryan Doel
el 4 de Mzo. de 2017
Respondida: Ryan Doel
el 23 de Mzo. de 2017
close all; clear;
x = -100:.05:100; y = -100:.05:100;
[X,Y] = meshgrid(x,y);
%positive charge at x =0 y = 0
u = 25*X./(X.^2 + Y.^2).^1.5; %x-hat
v = 25*Y./(X.^2 + Y.^2).^1.5; %y-hat
%negative charge at x=0 y=-5
u2 = -30*X./(X.^2 + (Y+5).^2).^1.5; %x-hat
v2 = -30*(Y+5)./(X.^2 + (Y+5).^2).^1.5; %y-hat
%creating streamline starting points
%in a circle about the positive charge
theta = 0:pi/9:2*pi;
startx = 1*cos(theta);
starty = 1*sin(theta);
%plot the streamlines in the X-Y Plane
figure;
streamline(X,Y,u+u2,v+v2,startx,starty)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/161345/image.png)
0 comentarios
Respuesta aceptada
Rahul Kalampattel
el 4 de Mzo. de 2017
Editada: Rahul Kalampattel
el 4 de Mzo. de 2017
If you check out the documentation for the streamline function, you'll see that you can specify the maximum number of vertices the streamline will have (i.e. how long each streamline is).
By changing the last line of your code to this:
streamline(X,Y,u+u2,v+v2,startx,starty,[0.1,20000])
where 0.1 is the step size (default) and 20,000 is the max number of vertices, the plot looks like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/173019/image.png)
0 comentarios
Más respuestas (1)
Ver también
Categorías
Más información sobre Vector Fields en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!