Question about variables/efield

I have been having problems setting up a good way to make a
non-uniform electric field, is there a way to calculate a variable
based on a given atom's position? I tried using

variable Ex equal 2*(x-10)
and variable Ex atom 2* (x-10)

I think I'm misunderstanding the variable page.

Also, Ideally I would use a finite element method to get the electric
field, is there a way to set the index to a given variable for each
atom?

thanks,

~Nickhil

You need an atom-style variable, not an equal-style.
The former can include the position of the atom in
the formula.

Steve