MATLAB Answers

# How to extrapolate a curve using a data set?

24 ビュー (過去 30 日間)
Evan Augustine 2021 年 3 月 25 日

Hello,
I'm trying to create a function that using inputted data from previously established data sets, is able to create a well fitting curve that continues past the values of the actual data set. I've looked into the function polyfit but I was wondering if any other functions would work better for this?
Thank you

サインインしてコメントする。

### 採用された回答

Matt J 2021 年 3 月 25 日

If your curve is a polynomial, then polyfit is definitely the best, but you can also look at fit, nlinfit, lsqcurvefit, spline, interp1, griddedInterpolant, and many File Exchange submissions.

サインインしてコメントする。

### その他の回答 (1 件)

John D'Errico 2021 年 3 月 25 日
Ah, if people were able to accurately and easily extrapolate data, then everyone would agree about things like global warming. Ok, in fact, most do agree about that, but you know what I mean. In general, extrapolation is difficult to do well. If you want good results, then you need a good PHYSICAL model, that treats the problem properly. Is a polynomial model a good model? NO! Polynomials are terrible at extrapolation. You might as well close your eyes, spin around (roughly) ten times, and then hope to hit the dart board. I'd strongly suggest using Velcro darts if you try.
The point is, a polynomial has NO physical reason to expect to predict well where it was not predicting the data. In fact, polynomials tend to do all sorts of strange and stupid looking things. A straight line is the only fit that I am generally willing to extrapolate, so a first degree polynomial.
And that means again, that you need to understand the process you desire to extrapolate. If not, then you get what you deserve. To quote Mark Twain from Life on the Mississippi (1884):
“In the space of one hundred and seventy six years the Lower Mississippi has shortened itself two hundred and forty-two miles. That is an average of a trifle over a mile and a third per year. Therefore, any calm person, who is not blind or idiotic, can see that in the Old Oölitic Silurian Period, just a million years ago next November, the Lower Mississippi was upwards of one million three hundred thousand miles long, and stuck out over the Gulf of Mexico like a fishing-pole. And by the same token any person can see that seven hundred and forty-two years from now the Lower Mississippi will be only a mile and three-quarters long, and Cairo [Illinois] and New Orleans will have joined their streets together and be plodding comfortably along under a single mayor and a mutual board of aldermen. There is something fascinating about science. One gets such wholesale returns of conjecture out of such a trifling investment of fact.”
The point is, you need some intelligent model that can be used to extrapolate. That is often a nonlinear model, that carefully emulates the system under study. Or else, get random results. Or get any result you want, merely by use of some carefully chosen extrapolant that does as you want it to do.

サインインしてコメントする。

R2020b

### Community Treasure Hunt

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

Start Hunting!

Translated by