# Why when you use any filter, it results first a steepness at the beginning to a certain level?

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.

• 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
– JLo
Jun 10, 2020 at 7:52
• It 's a possible option yes. I have to see how to master that function. Thank you Jun 10, 2020 at 15:27

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

• Hi Knut Inge, do you mean to <<y = filter(b,a,x,zi)>> where <<zi>> is the initial condition? Jun 11, 2020 at 18:08
• I mean as documented here: se.mathworks.com/help/signal/ref/filtic.html Jun 11, 2020 at 18:42
• An interesting solution. Thank you. Jun 12, 2020 at 10:02
• 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. 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.

• 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. Jun 10, 2020 at 15:36