Doubts about using regression (Matlab)

I have a data set (Col_A and Col_B) and I need to find the value of Col_B when Col_A is 0.
Col_A Col_B
983 235.2
960 237.1
945 225.9
I've tried several commands, such as fit, fitlm, polyfit, regress but the results are not as expected.
When I use Excel to find the Trendline and find the value if I create the "Insert Scatter (X, Y) or Bubble Chart" graph, I find the values close to what I find in Matlab (which does not correspond with what search) when I create the graph using the "Insert Line or Area Chart" the value found by the trend line is within the expected.
However, I cannot find this value through Matlab.
Codes I've used
fit(Col_A,Col_B,'poly2')
fitlm(Col_A,Col_B,'poly2')
regress(Col_A,Col_B)
polyfit(Col_A,Col_B,2)
polyfit(Col_A,Col_B)

8 个评论

Your data is very far from what you're looking for. Any trend line you will fit to only 3 points will be close to meaningless if you don't know the underlying function and only need to fit the parameters.
Can you confirm you want to fit a second order polynomial?
Some samples have more than 3 data, the ideal would be to use the same adjustment for all samples, so I was trying with a polynomial, but more importantly, the value found should be close to the expected value
Your data range is 945-983. How will you prevent garbage outcomes if you try to extrapolate to 0? You can indeed use a polynomial, but you need to make sure you know enough about the system you're modeling to decide if that makes sense. You could also fit a sine wave to your data.
So again: are you very sure you need a second order polynomial specifically?
I just need an approximate and plausible value for for Col_B when Col_A = 0, and I used a second order polynomial just because the curves are not linear, but I could use a first order polynomial without any major problems. I need this value only as an initial condition for other calculations and therefore I need an approximate value only.
Perhaps you are over complicating it. If a linear model would work as well as a 2nd order polynomial for your needs (which would result in very different values), what about just hard coding a generic value?
Because in practice this value changes every moment (but they are all in a range of values) and if I consider only one value the final results would practically not vary (I already tried this) and I would not like to assign random values.
If you want a different value every time you could also consider using the mean of your data.
I think using mean will be the simplest solution

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Polynomials 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by