Doubts about using regression (Matlab)
Show older comments
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 Comments
Rik
on 11 Jan 2021
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?
Juliano Cardoso
on 11 Jan 2021
Rik
on 11 Jan 2021
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?
Juliano Cardoso
on 11 Jan 2021
Cris LaPierre
on 11 Jan 2021
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?
Juliano Cardoso
on 11 Jan 2021
Rik
on 11 Jan 2021
If you want a different value every time you could also consider using the mean of your data.
Juliano Cardoso
on 11 Jan 2021
Answers (0)
Categories
Find more on Polynomials in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!