필터 지우기
필터 지우기

Extrapolation of data points

조회 수: 48 (최근 30일)
Joana Silva
Joana Silva 2019년 8월 9일
댓글: riadh euldji 2021년 6월 22일
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
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
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
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
Joana Silva
Joana Silva 2019년 9월 19일
Thanks very much Jon!
It works perfectly! :)
You are right John!
I tested and knew this before.
My solution will depende on the number of points I choose.
I think for the calculations I want to do, 1.0341 or 1.0357 will not have a big impact. But I'm not sure, I need to look at that.
I used the error propagation before in some measurements of my experiments, so I can use it for this as well.
Thanks :)
riadh euldji
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 CenterFile Exchange에서 Uncertainty Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by