Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
polyfit

Subject: polyfit

From: Judy

Date: 20 Nov, 2008 19:59:02

Message: 1 of 4

Polyfit has given me a warning message saying:
Warning: Polynomial is badly conditioned. Remove repeated data points
         or try centering and scaling as described in HELP POLYFIT.

The help polyfit says:
Warning messages result if N is >= length(X), if X has repeated, or
    nearly repeated, points, or if X might need centering and scaling.

What does it mean when X might need centering and scaling? My N is < length(X)

Thanks!

Subject: polyfit

From: Peter Perkins

Date: 20 Nov, 2008 21:05:47

Message: 2 of 4

Judy wrote:
> Polyfit has given me a warning message saying:
> Warning: Polynomial is badly conditioned. Remove repeated data points
> or try centering and scaling as described in HELP POLYFIT.

>> help polyfit
 POLYFIT Fit polynomial to data.
[snip]
    [P,S,MU] = POLYFIT(X,Y,N) finds the coefficients of a polynomial in
    XHAT = (X-MU(1))/MU(2) where MU(1) = MEAN(X) and MU(2) = STD(X). This
    centering and scaling transformation improves the numerical properties
    of both the polynomial and the fitting algorithm.

and then

>> help polyval
POLYVAL Evaluate polynomial.
[snip]
    Y = POLYVAL(P,X,[],MU) or [Y,DELTA] = POLYVAL(P,X,S,MU) uses XHAT =
    (X-MU(1))/MU(2) in place of X. The centering and scaling parameters MU
    are optional output computed by POLYFIT.

You are most likely fitting a polynomial that is of a high degree, and your x values are things like year numbers.

Hope this helps.

Subject: polyfit

From: Judy

Date: 20 Nov, 2008 22:10:19

Message: 3 of 4

Peter Perkins <Peter.PerkinsRemoveThis@mathworks.com> wrote in message <gg4jfb$9qa$2@fred.mathworks.com>...
> Judy wrote:
> > Polyfit has given me a warning message saying:
> > Warning: Polynomial is badly conditioned. Remove repeated data points
> > or try centering and scaling as described in HELP POLYFIT.
>
> >> help polyfit
> POLYFIT Fit polynomial to data.
> [snip]
> [P,S,MU] = POLYFIT(X,Y,N) finds the coefficients of a polynomial in
> XHAT = (X-MU(1))/MU(2) where MU(1) = MEAN(X) and MU(2) = STD(X). This
> centering and scaling transformation improves the numerical properties
> of both the polynomial and the fitting algorithm.
>
> and then
>
> >> help polyval
> POLYVAL Evaluate polynomial.
> [snip]
> Y = POLYVAL(P,X,[],MU) or [Y,DELTA] = POLYVAL(P,X,S,MU) uses XHAT =
> (X-MU(1))/MU(2) in place of X. The centering and scaling parameters MU
> are optional output computed by POLYFIT.
>
> You are most likely fitting a polynomial that is of a high degree, and your x values are things like year numbers.
>
> Hope this helps.

Thanks for the reply! It is true, it is fitting a polynomial of a high degree.. It doesn't look like I can do much for the indices of x.... . . . Would anyone recommend ignoring the warnings in this situation? Or is it telling me something here....

Subject: polyfit

From: Peter Perkins

Date: 21 Nov, 2008 16:27:58

Message: 4 of 4

Judy wrote:

> Thanks for the reply! It is true, it is fitting a polynomial of a high degree.. It doesn't look like I can do much for the indices of x.... . . . Would anyone recommend ignoring the warnings in this situation? Or is it telling me something here....

It is telling you that your problem is numerically ill-posed, and that you should not be doing what you are doing. As I said, either stop using such a high degree polynomial, or scale your data by using the appropriate arguments to polyfit.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us