Hi,
I am assuming that you would like to plot in 3D, components of the magnetic field that are parallel to the tangent of a sphere.
As a first step, you have created a plot of the magnetic field. As a second step the gradient plot was done which clearly shows the tangents at various points on the surface of the sphere.
As a third step, you have identified the dot product of the point and its gradient. There are two issues.
1. You have an array of vectors 2. The dot product of the points and its gradient doesn't give the necessary angle between the magnetic field and the gradient.
So since an array of vectors are under consideration, the 'dot' function doesn't work directly for the dot product. But it has to be manually done for vectors.
If you have two vectors say, a = a1x+a2y+a3z and b = b1x+b2y+b3z, then a.b = (a1*b1)+(a2*b2)+(a3*b3). Now extrapolate it considering the coefficients as matrices. So in your code,
A = U.*dx; B = V.*dy; C = W.*dz;
Finally adding them would give the dot product.
k = A+B+C;
Now we have the dot product which gives us the angle information between the magnetic field and the gradient (the surface of the sphere). In order to find the components of the magnetic field along the surface of the sphere, dot product will not be sufficient but the projection of magnetic field vector on the gradient vector has to be found.
So if a and b are the vectors as shown above, then projection of a on be can be written as,
projaonb = dot(a,b)*unitVector(b) = dot(a,b)* b / b.
So implementing it here for this problem.
k1 = k./sqrt(dx.*dx + dy.*dy + dz.*dz); projx = k1.*dx; projy = k1.*dy; projz = k1.*dz;
quiver3(X, Y, Z, projx, projy, projz);
Now you should possibly see the components of magnetic field vector along the tangent vectors.
-Venkatachala Sarma
Best Answer