Filter löschen
Filter löschen

Extrapolation of data points

58 Ansichten (letzte 30 Tage)
Joana Silva
Joana Silva am 9 Aug. 2019
Kommentiert: riadh euldji am 22 Jun. 2021
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 Kommentare
Star Strider
Star Strider am 9 Aug. 2019
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 am 9 Aug. 2019
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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jon
Jon am 9 Aug. 2019
Bearbeitet: Jon am 9 Aug. 2019
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 Kommentare
Joana Silva
Joana Silva am 19 Sep. 2019
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 am 22 Jun. 2021
@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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by