Hi, I have a coded a function that (using quiver3) produces vectors on the surface of hemisphere. However, the component of the vector that interests me is the component that lies parallel to tangent of the surface of the sphere. I have also plotted the tangent vector that points along the sphere using gradient and the quiver3 function. Here is my code:
if trueR=22; phi=linspace(0,pi,50); theta=linspace(-pi/2,pi/2,50);[phi,theta]=meshgrid(phi,theta);X=R*sin(phi).*cos(theta); Y=R*sin(phi).*sin(theta); Z=R*cos(phi);k=50; T=Z./R;%U=3*k*Z.*sin(acos(T))./R.^4; %mag field in x
%V=3*k*Z.*sin(acos(T))./R.^4; %mag field in y
%W=2*k*((3*Z.^2 ./ R.^2)-1)./R.^3; % mag field in z %magnetic field function
U=3*k.*sin(theta).*cos(theta).*cos(phi).*R.^-3V=3*k.*sin(theta).*cos(theta).*sin(phi).*R.^-3W=3*k*(((cos(theta)).^2)-1./3).*R^-3quiver3(X,Y,Z,U,V,W,1)% no defines arrow length, other define direction, defines arrow direction (u,v,w) at point (x,y,z)
hold ondx=gradient(X)dy=gradient(Y)dz=gradient(Z)quiver3(X,Y,Z,dx,dy,dz)axis equal % code
end
I now want to perform a dot product of these two vector at each point on my sphere to produce a 3D image of how the tangential component of the original function varies throughout the surface of the sphere.
To do this I tried to create 3 more vectors that corresponded to the dot product of U and X, V and Y and W and Z and then use the quiver3 function to display them.
if trueA=dot(X,dx)B=dot(Y,dy)C=dot(Z,dz)quiver3(X,Y,Z,A,B,C)% code
Which has not worked, any suggestions would be appreciated. Thanks John
Best Answer