quadratic fit tool wrong coefficients

I have plotted a large data list of 46 points where I plot the temperature against wavelength. Then I fit with the toolbox from matlab and I get a nice quadratic comparison. If that equation is then used to enter values, it appears that there is a mistike with the fit. Is there anyone who can help me with this problem?

5 件のコメント

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 11 月 14 日
The question is not clear for me, can you illustrate it with figure?
sander de lange
sander de lange 2019 年 11 月 14 日
plot.PNG
Looky
Looky 2019 年 11 月 14 日
Did you use the displayed formular or the calculated coefficients?
Simple test: your x values are roughly 1e-6 , squared and multiplied with the first coefficient of 5.4e18 this leaves something like 5e6 but your y values are 1e2. This means you will need at least 5 diggits of your first coeffcient, but better go with 7 or 8.
Also, be aware that while the fit looks good, it is most likely untrustworthy out of your x region. Have a look at the confidence bounds of the coeffcient parameters. So what do you want to do with it?
sander de lange
sander de lange 2019 年 11 月 15 日
I want to be able to calcute with the fit. If I now measure a wavelength via the fit, I can calculate a temperature, then I want to measure the temperature and then compare this measured value with the calculated temperature, but if I now calculate with the fit, very strange temperatures will come out . Because when I get fit I get the message: polynomial is badly conditioned. Add points with distinct x values, select a polynomial with a lower degree, or select Center and scale data x data. My questions are for this story:
-What does this message mean?
- And why is this fit the right one?
Looky
Looky 2019 年 11 月 18 日
The error message mostly comes from your very small x-values. Fitting works best if you normalize and center your data. This has statistical and numerical reasons, ask google for details. What to do against this problem, you can read in the answer by Steven Lord below.
If you use the curve fitting toolbox (cftool) it is a matter of ticking a box. (if you have a problem there, just comment under Steven Lords answer).
However, in your case this only solves part of the problem. If you look at your data it looks very much like a line with a very small curvature. A parabola works okay in modelling this, because two of the three parameter for a parabola describe a line already.
Parabola: f(x) = p1*x^2 + p2*x + p3
where p2 and p3 can describing a simple line.
However, the distinct characteristics of a parabola (the vertex/turning point or the axis of symmetry) are not present in your data. This is a problem for your fit, since the parameter p1 can have many different values that will all give a parabola that fits your data in your x-region well. (I can go into more detail if that is of interest)
This means, your fit will (after centering and normalizing) have p2 and p3 with goodish confidence bounds and p1 with a horrible confidence bound (untrustworthy).
However, as you can see, the curve itself works perfectly to describe the behaviour of your data within the give x-region.
The question you have to ask yourself now is:
Is it okay if the fit works only within the given x-region?
If yes, that read through Steven Lords answer and you're done.
If no, then you have a problem, because the prediction your fit can make outside your x-region is not really trustworthy unless you have anymore information on how the parabola might look. E.g.: at a wavelength of x the temperature must be zero or any other physical meaning that might help in improving the fit.

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

回答 (1 件)

Steven Lord
Steven Lord 2019 年 11 月 14 日

0 投票

Because your parameters are so large, I strongly encourate you to center and scale your data as shown in step 7c in the first example on this documentation page (if you're using the Curve Fitting App) or the "Modify Default Fit Options to Normalize Data" and "Use Identical Fit Options in Multiple Fits" examples on this documentation page (if you're doing programmatic fitting.)
As Looky indicated, the coefficients displayed when you display the fit object do not show the full precision of the coefficients. If you want to evaluate the fit, evaluate the fitted curve or fitted surface directly. This is especially important if you center and scale your data as evaluating the object will automatically apply the same normalization to the data with which you evaluate the fit object.

カテゴリ

ヘルプ センター および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

製品

リリース

R2019a

タグ

質問済み:

2019 年 11 月 14 日

コメント済み:

2019 年 11 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by