MATLAB: How remove plateaus on plot

concatenateplateauremove

I want create a script that remove the plateau in red on the plot (figure) and concatenate the rest of the data. I have large data set. Thanks

Best Answer

t=1:numel(y)
d=abs(gradient(y,t))
y(d<0.4)=[];
plot(y)