Delay when using lowpass(), medfilt1() and filter()

Hello,
I'm trying to filter a data signal and I'm using y = lowpass(x,fpass,fs), medfilt(x),filter(b,a,x) for this.
I'm not sure if these functions in matlab introduce a delay to the signal or if they compensate themselves for this delay.
If they are how can I compensate for this delay?

 Accepted Answer

The filter function introduces phase delay and phase dsitortion in the filtered signal. The filtfilt function does not, so it is best to use filtfilt for most signal processing applications.
The lowpass function (apparently) uses filtfilt rather than filter, because when I have used the second (optional) output of lowpass that returns a digital filter object, I get the same results as the lowpass function with filtfilt although not with filter.
The medfilt1 function does not mention how it filters the data, only that it ‘considers the signal to be 0 beyond the endpoints.

4 Comments

Thank you for your answer. Does this mean, if I use lowpass function, I don't have to account later for the delay? But, for filter function, I should and it is a shift of the output signal?
As always, my pleasure!
The ‘y’ output of lowpass apparently uses filtfilt, so there is no delay or phase distortion. There is therefore no delay.
I would not use filter for most signal processing applications because it introduces phase delay and phase distortion. Use filtfilt instead, since it is a phase-neutrai (or ‘zero phase’) filtering function. There is no need to account for phase delay with filtfilt because it does not introduce any phase delay. (The filtfilt function has been part of the Signal Processing Toolbox for as long as I can remember, so you should have it.)
Thank you again. Your answer is very helpful.
As always, my pleasure!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!