2
$\begingroup$

I have the following code, and I've tried almost everything I can think of, even VectorColorFunction to describe magnitude. I am trying to make the length of the vectors proportional to r^{-2}, and without Norm[efield] it only plots a single arrow. Here is what I have:

f[x_, y_] = (x^2 + y^2)^(-1/2); 
efield = g[x_, y_] = Grad[f[x, y], {x, y}];

VectorPlot[(-efield)/Norm[efield], {x, -10, 10}, {y, -10, 10},
 AspectRatio -> Automatic, VectorScale -> {Medium, Scaled[0.35]}]

The vectors are all the same length; any ideas?

$\endgroup$
0

1 Answer 1

2
$\begingroup$

This seems to do the right thing:

VectorPlot[(-efield), {x, -10, 10}, {y, -10, 10}, AspectRatio -> Automatic, VectorScale -> {Automatic, Automatic, 1/#5^2 &}]

(although you might want to twiddle the scaling parameter). Notice that the scaling function is a function of five parameters, of which the norm of the gradient is the last, hence #5.

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.