Code: Select all
[x,y,z] = meshgrid(-12E6:2000000:12E6,-12E6:2000000:12E6,-12E6:2000000:12E6);
G=6.67421E-11;
M=5.97E24;
m=80;
F1 = -G*M*m.*x.*(x.^2+y.^2+z.^2).^(-1.5);
F2 = -G*M*m.*y.*(x.^2+y.^2+z.^2).^(-1.5);
F3 = -G*M*m.*z.*(x.^2+y.^2+z.^2).^(-1.5);
quiver3(x,y,z,F1,F2,F3)
xlabel('x')
ylabel('y')
zlabel('z')
Edit: In testing this script in QtOctave, I found that for some reason it doesn't display any vectors in the field, just empty space, even though quiver3 appears to be a function, so I don't know why it doesn't work, sorry about that .
Edit 2: Here's a picture: