Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Trouble using polyfit that separated straight fit from original
data points

Replies: 1   Last Post: Nov 4, 2013 7:59 AM

 Messages: [ Previous | Next ]
 Torsten Hennig Posts: 2,419 Registered: 12/6/04
Re: Trouble using polyfit that separated straight fit from original
data points

Posted: Nov 4, 2013 7:59 AM

> Hi all,
>
> Thought I might post here too.
>
> I am plotting some data from a power-inverse law and
> using the following:
>
> loglog(E2dist,E2PrdB,'+g'), hold on
>
> p = polyfit(log(E2dist),log(E2PrdB),1);
>
> m = p(1);
>
> b = exp(p(2));
>
> %mean=mu(1);
>
> %std=mu(2);
>
> loglog(E2dist, b.*E2dist.^m,'-m*');
>
> This works fine. But when I change the polyfit line
> to
>
> [p,S,mu] = polyfit(log(E2dist),log(E2PrdB),1);
>
> so that I can get standard deviation etc. my straight
> line fit is moved vertically up from my original data
> points? I notice that the log of my first dist point
> 1m is coverted to 0. Not sure if that would move it
> and how to correct it.
>
> Hope you can help.
>
> cheers

Did you notice that when you call polyfit as
[p,S,mu] = polyfit(log(E2dist),log(E2PrdB),1);
the resulting regression polynomial will be a function of
x^= (x-mu)/sigma instead of x ?

Best wishes
Torsten.

Date Subject Author
11/4/13 James
11/4/13 Torsten Hennig