title: removal of DC offset using highpass fft filter
body: <p>I have some data that has a DC offset and might have a slight slope. The signal are two main peaks (similar to a gaussian) followed by decaying oscillations.</p>
  
  <p>I tried the following code, but this does not remove a DC offset - it removes a curved offset (sinus?).</p>
  
  <pre><code>function [ filteredData ] = fourierFilter( inputData )
  
  factor = 8;
  N = 1024*factor;
  dataRaw = zeros([1 N]);
  dataStart = N/2 - round(size(inputData,2)/2);
  indices = dataStart:(dataStart+size(inputData,2))-1;
  dataRaw(indices) = inputData;
  
  % transform to fourierspace
  fourierSpectrum = (fftshift(fft(dataRaw)));
  
  % add filter
  delta = 1*factor/4;
  indicesfftfilter = N/2-delta:N/2+delta;
  fourierSpectrum(indicesfftfilter) = 0;
  
  % back transform
  filteredData = real(ifft(ifftshift(fourierSpectrum)));
  filteredData = (filteredData(indices));
  </code></pre>
  
  <p>Here an example of the data (blue) and a filtered curve (red) with <code>delta = 3*factor/4</code></p>
  
  <p><img src="https://i.stack.imgur.com/bijRm.png" alt="enter image description here"></p>