Extrapolation of data points
조회 수: 39 (최근 30일)
이전 댓글 표시
Hi everyone.
I have plotted a set of x and y values (See pictures attached).
I want to extrapolate the two curves until they intercept each other.
Can anyone help me with this?
Thank you :)
댓글 수: 3
Star Strider
2019년 8월 9일
Will they ever intersect?
You have no idea what the data do beyond the values you have measured and plotted. If you have a mathematical model that correctly describes the process that created your data, and you have accurately estimated its parameters, you might be able to extrapoilate your data. That still does not mean that the curves will intersect.
So just take a wild guess as to where they will intersect. It will be as accurate as anything you can calculate!
Jon
2019년 8월 9일
I also noted in my answer that the curves are very close to being parallel and that the extrapolated intersection is likely to be very sensitive to the extrapolation procedure.
채택된 답변
Jon
2019년 8월 9일
편집: Jon
2019년 8월 9일
You could first find the equation of a straight line that goes through the last n points of one curve, and then similarly find an equation of a straight line that goes through the last n points of the second curve. Given these two equations, you can easily solve analytically (routine algebra) to find there intersection, or you could plot the two lines along with your original data and see the intersection graphically.
To get the equation of a straight line through the last n points you could use something like
p1 = polyfit(x1(end-n:end),y1(end-n:end),1) % p1(1) is slope, p1(2) is intercept
p2 = polyfit(x2(end-n:end),y2(end-n:end),1) % p2(1) is slope, p2(2) is intercept
if you wanted to plot these two straight lines out to the extrapolated region
% define final values for extrapolation and number of points to plot
numPoints = 50;
xfinal = 100;
xfit1 = linspace(x1(end-n),xfinal,numPoints)
xfit2 = linspace(x2(end-n),xfinal,numPoints)
yfit1 = polyval(p1,xfit1)
yfit2 = polyval(p2,xfit2)
plot(x1,y1,xfit1,yfit1,x2,y2,xfit2,yfit2)
With a little more thought you could make the x's, y's etc into matrices, and make little loops so you wouldn't have to do everything twice.
Note: The curves look like they are quite close to being parallel, so, your extrapolated intersection will be very sensitive to how you choose to define your extrapolation (very slight shifts in the slopes or intercepts of the extrapolated lines will make big shifts in the intersection point)
Finally as @Alex suggests, you could use interp1 to do the extrapolation, but for example if you chose the 'linear' method I think it would only use the last two data points for the extrapolation, which might be less robust than the approach I outlined above. It would however be very simple to use interp1, if it works well enough.
댓글 수: 8
riadh euldji
2021년 6월 22일
@Jon hello dr jon i hope that you are doing well
am about to extrapoliate data from excel file the calculeted data i that i got from the extrapolation are NAN and when i change the method for exmlpe i use linear method i got negative value could you sir help me
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Descriptive Statistics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!