Documentation Center

  • Trial Software
  • Product Updates


dsp.DCBlocker System object

Package: dsp

Remove DC component


The DCBlocker object filters or blocks the DC component of an incoming signal.

To filter the DC component of a signal:

  1. Define and set up your DC blocker object. See Construction.

  2. Call step to filter the DC component of a signal according to the properties of dsp.DCBlocker. The behavior of step is specific to each object in the toolbox.


H = dsp.DCBlocker creates a DC blocker System object™, H, that removes the DC component of each channel, i.e., column, of an input signal.

H = dsp.DCBlocker(Name,Value) creates a DC blocker object, H, with each specified property set to the specified value. You can specify additional name-value pair arguments in any order as (Name1,Value1,...,NameN,ValueN).



DC offset algorithm type

Specify the DC offset estimating algorithm as one of IIR | FIR | Subtract mean. You can visualize the IIR and FIR responses using the fvtool method. The default is IIR.

  • IIR uses a recursive estimate based on a narrow, low-pass elliptic filter. You specify the filter order using the Order property and you set the bandwidth using the NormalizedBandwidth property. This algorithm typically uses less memory than FIR and is more efficient.

  • FIR uses a non-recursive, moving-average estimate based on a finite number of past input samples that is set using the Length property. This algorithm typically uses more memory than IIR and is less efficient.

  • Subtract mean computes the means of the columns of the input matrix and subtracts the means from the input. This method does not retain state between inputs.


Normalized bandwidth of the low-pass, IIR, elliptic filter

Specify the normalized bandwidth of the IIR filter used to estimate the DC component of the input signal as a real scalar greater than 0 and less than 1. This property applies when the Algorithm property is set to IIR. The default value is 0.001.


Order of the low-pass, IIR, elliptic filter

Specify the order of the IIR elliptic filter used to estimate the DC level. This property applies when the Algorithm property is set to IIR. Use an integer greater than 3. The default value is 6.


Number of past input samples for the FIR algorithm

Specify the number of past inputs used to estimate the running mean. This property applies when the Algorithm property is set to FIR. Use a positive integer. The default value is 50.


cloneCreate DC blocker object with same property values
fvtoolShow the frequency response of the filter used by the DCBlocker System object
isLockedLocked status for input attributes and nontunable properties
releaseAllow property value and input characteristics changes
resetReset states of the DCBlocker System object
stepBlocks DC components of input signal


expand all

Remove DC Component and Display Results

The step method is used in conjunction with the DCBlocker to remove the input signal's DC component using all three estimation algorithms.

Create a signal that is a sum of a 15 Hz tone, a 25 Hz tone, and a DC bias.

t = (0:0.001:100)';
x = sin(30*pi*t) + 0.33*cos(50*pi*t) + 1;

Create three DC blocker objects, one for each estimation technique.

hDC1 = dsp.DCBlocker('Order', 6);
hDC2 = dsp.DCBlocker('Algorithm', 'FIR', 'Length', 100);
hDC3 = dsp.DCBlocker('Algorithm', 'Subtract mean');

For each second of time, use the step method to apply the DC blockers to the input signal. By implementing the DC blockers in 1-second increments, you can see the convergence differences among the techniques.

for idx = 1 : 100
    range = (1:1000) + 1000*(idx-1);
    y1 = step(hDC1, x(range));          % IIR estimate
    y2 = step(hDC2, x(range));          % FIR estimate
    y3 = step(hDC3, x(range));          % Subtract mean

Plot the input and output data for the three DC blockers for the first second of time and show the mean value for each signal. You can see that the FIR and Subtract mean algorithms converge more quickly.

    t(1:1000),y1, ...
    t(1:1000),y2, ...
xlabel('Time (sec)')
legend(sprintf('Input DC:%.3f',    mean(x)), ...
    sprintf('IIR DC:%.3f',           mean(y1)), ...
    sprintf('FIR DC:%.3f',           mean(y2)), ...
    sprintf('Subtract mean DC:%.3f', mean(y3)));

Frequency Response Before and After DC Blocker

Compare the frequency response of the DC blocker using the FIR algorithm to the frequency response of the biased input signal.

Create an input signal composed of three tones with a DC bias of 1. Set the sampling frequency to 1 kHz and the signal duration to 100 seconds.

fs = 1000;
t = (0:1/fs:100)';
x = sin(30*pi*t) + 0.67*sin(40*pi*t) + 0.33*sin(50*pi*t) + 1;

Create a DC blocker object with the Algorithm property set to FIR.

hDCBlock = dsp.DCBlocker('Algorithm', 'FIR', 'Length', 100);

Create a SpectrumAnalyzer System object with power units set to dBW and a frequency range of [-30, 30] to display the frequency response of the input signal. Using the clone method, create a second spectrum analyzer to display the response of the output. Then, use the Name property to label the two objects.

hsa = dsp.SpectrumAnalyzer('SampleRate', fs, ...
    'PowerUnits','dBW','FrequencySpan','Start and stop frequencies',...
hsa.Name = 'Signal Spectrum';

hsb = clone(hsa);
hsb.Name = 'Signal Spectrum after DC Blocker';

Use the step method to apply the DC blocker to the input signal, x, to generate the output signal, y.

y = step(hDCBlock, x);

Use the step method of the hsa object to display the frequency characteristics of the input signal. Note the tones at 15 Hz, 20 Hz, and 25 Hz as well as the DC component.

step(hsa, x)

Use the step method of the hsb object to display the frequency characteristics of the output signal. The DC component has been removed.

step(hsb, y)


The DCBlocker System object subtracts the DC component from the input signal. The DC component is estimated by one of the following:

  • Passing the input signal through an IIR, low-pass, elliptical filter

  • Passing the input signal through an FIR filter that uses a non-recursive, moving average from a finite number of past input samples

  • Computing the mean value of the input signal

The elliptical IIR filter has a pass-band ripple of 0.1 dB and a stop-band attenuation of 60 dB. You specify the normalized bandwidth and filter order. The FIR filter coefficients are given as ones(1,Length)/Length, where you specify the Length parameter. The FIR filter structure is a direct form 1 transposed.

Selected Bibliography

[1] Nezami, M., "Performance Assessment of Baseband Algorithms for Direct Conversion Tactical Software Defined Receivers: I/Q Imbalance Correction, Image Rejection, DC Removal, and Channelization", MILCOM, 2002.

See Also


Was this topic helpful?