using quiver function to plot vectors on a hemisphere
3 ビュー (過去 30 日間)
古いコメントを表示
Hi, I'm trying to plot the magnetic field on the surface of a hemisphere (modelling a planetary dipole).
I have created a function magfield2 that produces the direction and magnitude of the magnetic field at some point (X,Y,Z) on the surface of a hemisphere, shown here:
if true
function [U,V,W] = magfield2(X,Y,Z) %U=mag force in X, V=mag force in Y, W=mag force in Z
r=(X.^2+Y.^2+Z.^2)^0.5 ;
U=3*X.*Z./(r.^5);
V=3*X.*Z./(r.^5);
W=((3*Z.^2 - r.^2)/r.^5);
% code
end
I then try to use this function with the quiver function to plot this magnetic field at the surface as shown here
if true
[X,Y,Z] = sphere(50); %defines meshgrid coverage
[U,V,W] = magfield2(X,Y,Z); %magnetic field function
figure
quiver3(X,Y,Z,U,V,W,0.5)% no defines arrow length, other define direction
%defines arrow direction (u,v,w) at point (x,y,z)
hold on
surf(X,Y,Z) %produces surface
view(-35,45)%canges initial viewing angle
axis([0 3 -1.5 1.5 -1.5 1.5]) %defines axis parameters
hold off
% code
end
Sadly, this just produces a hemisphere surface with no vectors on it. If I swap the magfield2 function with a surface normal function it seems to work fine.
Any comments/ suggestions would be appreciated. Thanks, John!
2 件のコメント
Star Strider
2015 年 11 月 29 日
The arrows plot (it seems to me correctly), but it’s difficult to see them because you scaled them to be short. Lengthen them to see them.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Vector Fields についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!