You are here: Symbol Reference > SignalUtils Namespace > Functions > SignalUtils.RemoveDC Function
DSP Master VCL
ContentsIndex
PreviousUpNext
SignalUtils.RemoveDC Function

Remove the DC component.

Pascal
function RemoveDC(const SrcDst: TVec; Index: integer; Len: integer = MtxVecEOA): TVec; overload;

Subtract the mean value of Data from Data. Works for stationary signals. Use a highpass FIR filter for signals with varying mean value or call the DcFilter routine, for an IIR version of the DC filter. Removing the DC component without applying a true FIR or IIR filter is often convinient prior to frequency analysis, because there is no run-in or run-out and no filter delay.

The sampling frequency is 256 Hz. A tone has a frequency 6Hz, amplitude 1 and DC offset is 4. 

 

    uses MtxExpr, Math387, MtxVec, SignalUtils, MtxVecTee, MtxVecEdit;

  procedure TForm1.Button1Click(Sender: TObject);
  var b,c,Response1, Response2: Vector;
  begin
      Tone(b, 256,6/256,0,1);
      b := b + 4; //generate 6 periods within 256 samples, Phase = 0, Amplt = 1
      c.Copy(b);
      RemoveDC(b);
      DrawIt([c,b],['Original signal','Signal without DC']);
      FrequencyResponse(c,nil,Response1,1,True);
      FrequencyResponse(b,nil,Response2,1,True);
      DrawIt([Response1, Response2],['Spectrum: original signal','Spectrum: signal without DC']);
  end;

 

  #include "MtxExpr.hpp"
  #include "MtxVecEdit.hpp"
  #include "MtxVecTee.hpp"
  #include "SignalUtils.hpp"

  void __fastcall TForm1::BitBtn1Click(TObject *Sender)
  {
      sVector b,c, Response1, Response2;

      b = Sin(Ramp(256, mvDouble, 0,2*PI*6/256)) + 4;
      c.Copy(b);
      RemoveDC(b);
      DrawIt(OPENARRAY(TVec*,(c,b)),OPENARRAY(AnsiString,("Original signal","Signal without DC")));
      FrequencyResponse(c,NULL,Response1,1,true);
      FrequencyResponse(b,NULL,Response2,1,true);
      DrawIt(OPENARRAY(TVec*,(Response1,Response2)),OPENARRAY(AnsiString,("Spectrum: original signal","Spectrum: without DC")));
  }
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!