Extrapolation gives wrong values when using interp1
조회 수: 77(최근 30일)
I have two different arrays and want to do interpolation and extrapolation.
X-value = [0 386.5 446.1 526.6 621.5 660.6 711.4 734.9 792.8 810.2 817.9 893.7 1136.8 1317 1420.2 1426.2]
Y-value = [1.225 1.216 1.203 1.194 1.182 1.178 1.171 1.169 1.161 1.160 1.160 1.151 1.122 1.101 1.091 1.091]
The y-value have a linear decrease with larger x-values. I want to do interpolation and extrapolation so I can find the y-value of any x-values. I have tried this code when I want to find the y-value when x- value is f.eks 2000:
When I try to extrapolation for x-values higher than the largest x-value value which is 1426.2, the y-value is not decreasing. Instead y-value stays nearly flat and even slightly increasing when x-value is increasing. The original curve is clearly decreasing linearly. I have no idea whats the problem. Hope someone can help.
Stephen23 2018년 3월 27일
편집: Stephen23 2018년 3월 28일
"Extrapolation gives wrong values when using interp1"
interp1 is giving the right value.
The problem is simple: the last two points have the same Y value, so any linear extrapolation will simply continue with that value. Linear interpolation/extrapolation of a new point takes into account (at most) only two data points, which means that the overall downward trend of your data is irrelevant, because the last two points are these:
X = [... 1420.2 1426.2];
Y = [... 1.091 1.091];
So all larger X values will simply return Y = 1.091, no matter how large you make X.
To resolve this you might want to add some smoothing, or do some subsampling, or fit a line (e.g. using least squares), or merge points that are close together, or ... whatever makes sense for your data.