We propose what to our knowledge is a new technique for modeling the kinetics of voltage-gated ion channels in a functional context, in neurons or other excitable cells. The principle is to pharmacologically block the studied channel type, and to functionally replace it with dynamic clamp, on the basis of a computational model. Then, the parameters of the model are modified in real time (manually or automatically), with the objective of matching the dynamical behavior of the cell (e.g., action potential shape and spiking frequency), but also the transient and steady-state properties of the model (e.g., those derived from voltage-clamp recordings). Through this approach, one may find a model and parameter values that explain both the observed cellular dynamics and the biophysical properties of the channel. We extensively tested the method, focusing on Na(v) models. Complex Markov models (10-12 states or more) could be accurately integrated in real time at >50 kHz using the transition probability matrix, but not the explicit Euler method. The practicality of the technique was tested with experiments in raphe pacemaker neurons. Through automated real-time fitting, a Hodgkin-Huxley model could be found that reproduced well the action potential shape and the spiking frequency. Adding a virtual axonal compartment with a high density of Na(v) channels further improved the action potential shape. The computational procedure was implemented in the free QuB software, running under Microsoft Windows and featuring a friendly graphical user interface.