Problem with variable command:

I’m a newcomer in this field. I have a system with two types of particles in it. Type 1 particles are within a spherical/spheroidal volume whereas there are only two type 2 particles outside the spherical/spheroidal volume. There are interactions between 1-1 and 1-2 type. The interactions contain a term which include the coordinates of both types of atoms. Can I use variable command in this framework?
I’m giving the term for your convenience.

Force between type1and type 2 =. …exp (-(coordinate_of_type1 - coordinate_of_type2)/connstant)
how can I implement this force??

You can't use the variable command to describe pairwise forces, that
will be used in a pair style. You could use pair_style table if there
is not already a LAMMPS pair style that does what you want.