How can I detrend a time series using cubic spline interpolation? I would like to get this done over for eg., 0.2 year bins.
John Michell answered .
2025-11-20
x = 0:100; y = 100*randn(1,length(x))+x.^2; xx = 0:10:100; yy = spline(x,y,xx);
Substract the trend from your original data and plot the detrended variation sequence.
ytrend = interp1(xx,yy,x,'spline'); subplot(2,1,1) plot(x,y,'.',x,ytrend); subplot(2,1,2) plot(x,y-ytrend)