Is there any tool to avoid that? For instance, I wish after filterin my signal, the filtered signal start from a certain level, in other words, at the offset level.

In this case, I've use Butterworth, second order, freq cut-off at 0.1 Hz and sample rate at 34 ms.

enter image description here

  • $\begingroup$ Maybe this is what you want? mathworks.com/help/signal/ref/filtfilt.html There are also functions to compute the initial value of the filter registers $\endgroup$
    – JLo
    Jun 10, 2020 at 7:52
  • $\begingroup$ It 's a possible option yes. I have to see how to master that function. Thank you $\endgroup$ Jun 10, 2020 at 15:27

2 Answers 2


For a filter with an input that you know will have a dc component, initialize the filter states (delay line) with the first sample.

Matlab have a dedicated function for this, filter_ic().

Another option, as suggested by hotpaw2 1. Subtract the assumed DC 2. Filter 3. Add the DC back in

  • $\begingroup$ Hi Knut Inge, do you mean to <<y = filter(b,a,x,zi)>> where <<zi>> is the initial condition? $\endgroup$ Jun 11, 2020 at 18:08
  • $\begingroup$ I mean as documented here: se.mathworks.com/help/signal/ref/filtic.html $\endgroup$
    – Knut Inge
    Jun 11, 2020 at 18:42
  • $\begingroup$ An interesting solution. Thank you. $\endgroup$ Jun 12, 2020 at 10:02
  • $\begingroup$ Hi Knut, a problem has come up. It turns out that filtic does not work when you apply a high-pass filter that removes low-frecuency components, then I have a signal without offset, but at the beginning the first offset value is still remaining. $\endgroup$ Jun 16, 2020 at 21:05

If the offset is known, or can be determined before applying the filter, you can subtract the offset from the signal before applying the filter, then add the offset back after filtering. If you don't know the offset, neither will the filter when it first starts.

  • $\begingroup$ Good option. From the beginning my idea was to get the offset after filtering, because I don't know beforehand. Viewing the signal, one can guess first take the mean from stationary state and do the following. Thanks for your answer. $\endgroup$ Jun 10, 2020 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.