Ns = 10000;
Ts = 1;
time = (1:Ns)*Ts;
a = 2;
b = 0;
T = 1e4;
slope = time/Ts * 0.0005;
trend = a * sin(2*pi*time/T) + b + slope;
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 = 0.2*randn(1,Ns);
close all
figure
plot(time,trend,'r-')
hold on
plot(time,trend+step,'g-')
plot(time,trend - 2, 'b--')
plot(time,trend + 1, 'k--')
plot(time,trend+step+noise,'mo')
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
1 Comment
Direct link to this comment
https://ww2.mathworks.cn/matlabcentral/answers/419825-how-to-robustly-estimate-low-and-up-envelope-of-signal-with-trend-few-level-constant-steps-and-nois#comment_612249
Direct link to this comment
https://ww2.mathworks.cn/matlabcentral/answers/419825-how-to-robustly-estimate-low-and-up-envelope-of-signal-with-trend-few-level-constant-steps-and-nois#comment_612249
Sign in to comment.