# Noisy signal filtering MATLAB

I'm currently working on rectifying a respiratory noisy signal shown below:

I've already tried to filter the noise as you can see in the image below (full image):

The red one is the noisy signal whereas the blue one is the one got after applying the non-linear detrending:

dt_ecgl = detrend(ecgl);
opol = 6;
[p,s,mu] = polyfit(t,ecgnl,opol);
f_y = polyval(p,t,[],mu);
dt_ecgnl = ecgnl - f_y;


And the green one is the reference signal (correct one) which I'm aiming to have as result of filtering. So my question is how can I acheive a better result? My goal is to have the blue and the green ones conbined (same exact shape) in other words how can I denoise such deformed signal in MATLAB or using any other platform?.

• Have you tried using a DC blocker? – Peter K. Apr 28 '16 at 22:04
• Look at iirnotch in MATLAB. It is exactly what you are looking for. – Amal Apr 30 '16 at 5:05
• Use a phase linear low-pass filter, optimize the cutoff frequency, q and slope to be such that you get close as possible to the result. Note that you aren't really removing the noise per-se, but just the frequencies that contain a lot of noise. If the noise falls withing the bandwidth of the signal, it will be much more difficult to remove. – Dole May 30 '16 at 11:04
• You could use frestimate and fit a filter/transfer function onto it. – fibonatic Aug 28 '16 at 23:16