Why am I missing streamlines?

11 visualizaciones (últimos 30 días)
Sophie Boswell
Sophie Boswell el 26 de Jun. de 2018
I'm trying to plot 3D streamline data but appear to be missing a section where the streamlines split off. Am I doing something wrong in my code or is this to do with the starting points I've chosen for stream3 to take?
xvals = linspace(-2,2,20);
yvals = linspace(-2,2,20);
zvals = linspace(-2,2,20);
[X,Y,Z] = meshgrid(xvals,yvals,zvals); %creates coordinate grid
%creates a symbolic expression for the Bfield By + iBx
syms Bfield(B0,x,y,a,b,c,d)
Bfield(B0,x,y,a,b,c,d) = -B0*( ((b*a^2 + 2*a*c*(x+1i*y) - (x+1i*y)^2 + 0.5*a^2)/sqrt((x+1i*y)^2 - a^2)) + 2*a*d*1i);
%defines 3d field
B = Bfield(1,X,Y,1,0.5,0,0);
Bx = sign(X).*imag(B) - 0.5*X ;
By = sign(X).*real(B);
Bz = 0.5*Z;
%defines test starting points for streamlines
i = 1:1:40;
sy = [ones(1,i(end))*0.001 ones(1,i(end))*-0.001];
sx = [0.1*sin(2*pi*i/i(end))+1 0.1*sin(2*pi*i/i(end))-1];
sz = [0.4*cos(2*pi*i/i(end)) 0.4*cos(2*pi*i/i(end))];
%finds streamline data back along spine of null and finds new starting
%points at the end of the spine
spineint = stream3(X,Y,Z,-Bx,-By,-Bz,sx,sy,sz);
length = size(spineint);
no = length(1,2);
sx = 0;
sy = 0;
sz = 0;
for j = 1:1:no
streamlines = spineint{1,j};
rc = size(streamlines);
r = rc(1,1);
sx(j) = streamlines(r,1);
sy(j) = streamlines(r,2);
sz(j) = streamlines(r,3);
end
%plots streamlines with starting points at end of the spine
figure
streamline(stream3(X,Y,Z,Bx,By,Bz,sx,sy,sz))
xlabel('x');
ylabel('y');
zlabel('z');
view(3);
This is the figure I'm getting using my code.
I am expecting to get something similar to this although not in the same orientation.
I'd appreciate any help you can give me. Thanks!

Respuestas (0)

Categorías

Más información sobre Assembly en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by