Removing baseline drift from ECG signal
You usually use a DC notch filter. This is a recursive filter that should kill a very narrow band of frequencies around DC. One possible implementation is a first order DC notch with transfer function

$$\frac{1 - z^{-1}}{1 - \lambda z^{-1}},$$

where $\lambda$ is some number very close to 1, say 0.99. A to demonstrate this in MATLAB,

b = [1 -1];
a = [1 -0.99];
freqz(b,a);




Notice that the phase response around DC gets pretty non-linear. Such is the nature of these recursive filters.

The closer you make $\lambda$ to 1, the narrower the notch gets and the more distorted your phase response becomes around DC.

For ECG signals, this will usually do. Experiment with $\lambda$ values that will suit your needs. Sometimes, if you make the notch too narrow, you won't get all off the drift, so 0.99 is usually a good starting point.