how to robustly estimate low and up envelope of signal with trend, few level constant steps and noise

4 views (last 30 days)
I am looking for robust estimation method of low and up envelope of the signal consisting from smooth trend component, constant steps between few fixed levels and additive noise (+ outliers of course). This question raised during my current research work on real life signal processing.
Typical example of signal is produced by following script:
%%signal definition
% number of samples
Ns = 10000;
% sampling period [secs]
Ts = 1;
time = (1:Ns)*Ts;
% trend component
a = 2;
b = 0;
T = 1e4;
slope = time/Ts * 0.0005;
trend = a * sin(2*pi*time/T) + b + slope;
% steps component (4 constant levels)
step = [zeros(1,1000),linspace(0,1,6),1*ones(1,500),linspace(1,0,6),zeros(1,500),linspace(0,-2,10), -2*ones(1,1200),linspace(-2,1,15),1*ones(1,3000),linspace(1,0,6), zeros(1,3000),linspace(0,-1,6), -1*ones(1,751)];
% noise component (normal noise)
noise = 0.2*randn(1,Ns);
% noise = 0.5*(rand(1,Ns)-0.5);
%%show signals component
close all
hold on
plot(time,trend - 2, 'b--')
plot(time,trend + 1, 'k--')
legend('trend','trend+steps','lowenvelope', 'upenvelope','trend+steps+noise')
title('smooth trend signal with constant steps between 4 levels and noise')
xlabel('time [sec]')
ylabel('value [-]')
hold off
See the following image
The separate signal components are unknown! Steps are always constant and between small number of fixed levels (typically < 4 or 5), so the estimated envelopes should be parallel to the trend signal. Noise is approximated by normal distribution with sigma ~0.1
Any idea how to solve this surprisingly difficult problem? Any relevant references or matlab code links?
  1 Comment
Michal on 19 Sep 2018
In principle I am looking for any robust estimation of trend signal component which is nearly parallel to real trend signal.

Sign in to comment.

Accepted Answer

Marcel Goldschen-Ohm
Marcel Goldschen-Ohm on 14 Nov 2021
Edited: Marcel Goldschen-Ohm on 14 Nov 2021
smBEVO, a new computer vision-based approach to single-molecule data series baseline drift estimation can solve this problem. smBEVO can identify each of the four levels in the data above and the overall baseline trend. Matlab function and app for smBEVO is available at along with an example of usage. I recommend the app for visualization. A preprint article describing smBEVO is available on bioRxiv at

More Answers (0)




Community Treasure Hunt

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

Start Hunting!

Translated by