The approach in the earlier post to to remove the linear trend the data was:
A = [x(:) ones(size(x(:)))]
c = A\y
yDetrended = y - (c(1)*x + c(2))
plot(x,yDetrended)
Looking at your new dataset signal_2.txt, it looks like the data now has a parabolic (quadratic) trend to remove.
You could modify the previous approach to instead fit a quadratic curve to the data and then subtract it off.
A = [x(:).^2 x(:) ones(size(x(:)))]
c = A\y
yDetrended = y - A*c
figure
plot(x,yDetrended)
p.s. If you have a signal_3.txt that has a cubic trend, I think you can figure out what to do from here :)
Best Answer