Why is the POLYFIT function in MATLAB unable to find a fit over my data values for 3rd and 4th order polynomial.

1 view (last 30 days)
I am using the POLYFIT function to fit a 3rd and 4th order polynomial over my data values
I get following warning message
Warning: Polynomial is badly conditioned. Add points with distinct X values, reduce the degree of the polynomial, or try centering and scaling as described in HELP POLYFIT.
My query is what would be the transformation equations for the 3rd and 4th order polynomial equations, wherein i had to extract [A,B,C,D] and [A,B,C,D,E], respectively.
Hope for the earliest reply.

Answers (2)

Image Analyst
Image Analyst on 27 Oct 2014
Try using all the arguments, like S and mu, and make sure you have at least 5 unique x points.
  1 Comment
Shaik Pasha
Shaik Pasha on 27 Oct 2014
Hi in my query i had mentioned a link which addresses a similar query but on 2nd order polynomial wherein mathworks team has mentioned polynomial transform equations for A,B,C. In similar manner i am expecting for 3rd and 4th order.
Thanks for the reply, i had tried with that option but its not reaching my expected result.

Sign in to comment.


Jan
Jan on 27 Oct 2014
Look into the code of polyfit and polyval. The scaling is implemented there. But you do not want to get the values of the fitted polynomial, but the coefficients. Anyway, if you have the formula for teh scaling of the x values, insert it to the polynomial equation, reorder the terms and you get the modified coefficients directly. This is very basic maths with plus, minus, division and multiplication. You can use the example the Mathworks team has posted to control, how this works for the polynomials of order 2. Exanding this to higher orders is not hard.
Please try this at least.

Categories

Find more on Polynomials in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!