This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

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.

    Note:   Starting in R2016b, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.


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

dcblker = dsp.DCBlocker(Name,Value) creates a DC blocker object, dcblker, 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 | CIC | Subtract mean. You can visualize the IIR, FIR, and CIC responses using the fvtool method. The default is IIR.

  • IIR uses a recursive estimate based on a narrow, lowpass 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.

  • CIC uses a lowpass filter that does not employ any multipliers. You specify the bandwidth of the filter using the NormalizedBandwidth property. If the Algorithm property is CIC, then fixed-point data must be input to the step function.

  • 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 lowpass IIR elliptic filter or the lowpass CIC filter

Specify the normalized bandwidth of the IIR or CIC 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 or CIC. The default value is 0.001.


Order of the lowpass 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.


fvtoolShow the frequency response of the filter used by the DCBlocker System object
resetReset states of the DCBlocker System object
stepBlocks DC components of input signal
Common to All System Objects

Create System object with same property values


Expected number of inputs to a System object


Expected number of outputs of a System object


Check locked states of a System object (logical)


Allow System object property value changes


expand all

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent step syntax. For example, myObject(x) becomes step(myObject,x).

This example shows how to use the DC Blocker System object to remove an input signal's DC component using three of the estimation algorithms.

Create a signal composed of a 15 Hz tone, a 25 Hz tone, and a DC offset.

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

Create three DC Blocker objects for the IIR, FIR, and Subtract mean estimation algorithms.

dc1 = dsp.DCBlocker('Algorithm','IIR','Order', 6);
dc2 = dsp.DCBlocker('Algorithm','FIR','Length', 100);
dc3 = dsp.DCBlocker('Algorithm','Subtract mean');

For each second of time, pass the input signal through the DC blockers. By implementing the DC blockers in 1 second increments, you can observe differences in the convergence times.

for idx = 1 : 100
    range = (1:1000) + 1000*(idx-1);
    y1 = dc1(x(range));          % IIR estimate
    y2 = dc2(x(range));          % FIR estimate
    y3 = dc3(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. Looking at the mean values for the three algorithm types, 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)));

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent step syntax. For example, myObject(x) becomes step(myObject,x).

This example shows a comparison of the spectrum of an input signal with a DC offset to the spectrum of the same signal after application of a DC blocker using the FIR estimation algorithm.

Create an input signal composed of three tones and a DC offset of 1. Set the sampling frequency to 1 kHz and set 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.

dcblk = 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',...

hsb = clone(hsa);

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

Pass the input signal, x, through the DC blocker to generate the output signal, y.

y = dcblk(x);

Use the spectrum analyzer, hsa, to display the frequency characteristics of the input signal. Note that the tones at 15 Hz, 20 Hz, and 25 Hz, and the DC component are clearly visible.


Use the second spectrum analyzer, hsb, to display the frequency characteristics of the output signal. Note that the DC component has been removed.


Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent step syntax. For example, myObject(x) becomes step(myObject,x).

This example shows how to use the DC Blocker to remove a DC offset from a fixed-point signal. The DC Blocker uses the CIC lowpass filtering method to estimate the DC offset.

Generate random binary data.

data = randi([0 1],1.2e5,1);

Modulate the data by creating a 64-QAM modulator System object and running its algorithm.

mod = comm.RectangularQAMModulator('ModulationOrder',64, ...
modOut = mod(data);

Determine the constellation reference points for the modulator.

cRefPts = constellation(mod);

Add AWGN to the modulated signal using the appropriate System object and running its algorithm.

noise = comm.AWGNChannel('EbNo', 14.75, ...
                          'BitsPerSymbol', 6, ...
                          'SignalPower', 42, ...
                          'SamplesPerSymbol', 1);
noisyOut = noise(modOut);

Display the scatter plot of the noisy signal by using a Constellation Diagram object. The red '+' markers show the ideal symbol locations.

constDiag = comm.ConstellationDiagram('Name','Noisy Constellation',...
    'ReferenceConstellation',cRefPts, ...
    'XLimits',[-8 8],'YLimits',[-8 8]);

Add a DC offset of 1 to the modulated signal.

noisyOut = noisyOut + 1;

Display the spectrum of the signal. The spike at 0 kHz is due to the introduced offset.

specAna = dsp.SpectrumAnalyzer(...
  'YLimits',[-40,40], ...
  'Title','Noisy Spectrum with DC Offset');

View the effect of the DC offset on the constellation. Observe that the constellation has shifted one unit to the right.

constDiag.Name = 'Noisy Constellation with DC Offset';

Convert the noisy signal to a signed, fixed-point object that has a 16-bit word length and an 11-bit fraction length.

noisyOut = fi(noisyOut,1,16,11);

Remove the offset by creating a DC Blocker object. Set the Algorithm property of the object to CIC.

dcblk = dsp.DCBlocker('Algorithm','CIC');

Visualize the frequency response of the CIC estimating filter.


Pass the offset, noisy signal through the DC Blocker and convert its output to a double.

dcBlockerOutFxP = dcblk(noisyOut);
dcBlockerOut = double(dcBlockerOutFxP);

Plot the signal spectrum to show the effect of removing the DC offset. The spike at 0 kHz has been removed.

specAna.Title = 'Noisy Spectrum with DC Removed';

Plot the constellation and verify that the signal shifted back to the left.

constDiag.Name = 'Noisy Constellation with DC Removed';

To see the effects of removing a DC offset, vary the value of the NormalizedBandwidth property.


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 lowpass 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

  • Passing the input signal through a CIC filter. Because the CIC filter amplifies the signal, the filter gain is estimated and subtracted from the DC estimate.

  • Computing the mean value of the input signal

The elliptical IIR filter has a passband ripple of 0.1 dB and a stopband 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.

The Cascaded Integrator-Comb (CIC) filter consists of two integrator-comb pairs. This helps to ensure that the peak of the first sidelobe of the filter response is attenuated by at least 25 dB relative to the peak of the main lobe. The normalized 3-dB bandwidth is used to calculate the differential delay. The delay is used to determine the gain of the CIC filter. The inverse of the filter gain is used as a multiplier which is applied to the output of the CIC filter. This ensures that the aggregate gain of the DC estimate is 0 dB.

The aggregate magnitude response of the filter and the multiplier is characterized by the following equation:


  • Bnorm is the normalized bandwidth such that 0 < Bnorm < 1.

  • M is the differential delay in samples.

  • N is the number of sections, equal to 2.

The differential delay is found by setting M to the smallest integer such that |H(e)| < 1/√2. Once M is known, the gain of the CIC filter is calculated as MN. Therefore, to precisely compensate for the filter gain, the multiplier is set to (1/M)N.

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.

Extended Capabilities

Introduced in R2014a

Was this topic helpful?