Variable resistor in LTSPICE
As Andy mentions, you just need to make your controlling source with a quantized voltage. The simplest way would be using a behavioural voltage with:
V = int(time*N)/N

Where time can also be any other time-dependent waveform you have (e.g. V(x)). As it is it ensures that there are 1/N Volts/step.
There are two main &quot;caveat emptor&quot;:

The more steps you'll need, the less resolution you'll have. For this, the behavioural sources have two parameters, tripdv (Volts) and tripdt (seconds). For rates of change that happen within tripdv/tripdt [V/s], the timestep is forced to a reduced form, trying to preserve the waveform. For values beyond, the timestep is not forced in any way and it may or may not &quot;fly-by&quot; (but most likely the former). These are preferred over imposing tighter timesteps, since the latter will force the simulation to crawl for all the duration, whereas the two parameters will only force it when needed. Adding .opt plotwinsize=0 will certainly help.

The usage of int() or its cousins, floor(), ceil(), or round() (but also if() &amp; co), will introduce discontinuities and these are the enemies of SPICE solvers. This means that your variable resistor will inherit these discontinuities which, depending on what simulation you have, may, or may not cause hiccups. Word of caution.


Other ways include creating your own circuit, maybe with the [SpecialFunctions]/sample, or with the A-devices, or simply various levels of voltage with VCSW. Not all will be as efficient, and not all will be simulation-time-friendly (some may turn out to be CPU hogs).