Re: plotting polyfit
- From: "Steven Lord" <slord@xxxxxxxxxxxxx>
- Date: Fri, 5 Aug 2005 09:29:37 -0400
"Madiha" <madiha.jafri@xxxxxxxxx> wrote in message
news:ef0fea9.-1@xxxxxxxxxxxxxxxxxxx
> Hi!
>
> I found a polynomial fit line for a set of data (using polyfit) for a
> certain x-axis range. Now I have been trying to plot the poly-line
> using the coefficients on a "different" x-axis range. I get a
> totally wrong plot! This may be silly and simple, but what am I doing
> wrong??
>
> ==========================
> d = [matrix of 1x101 data points];
> freq = 5e8:5.5e7:6e9
> freq2 = (freq - mean(freq))./std(freq); % normalized frequency,
> original 'freq' from 5e8 to 6e9 Hz
>
> p = polyfit(freq2, dielectric', 4)
> pop4 = polyval(p, freq2)
> plot(freq, pop4)
> ==========================
>
> The above code plots the polyfit line beautifully over my real data;
> however, when I take the coefficients from p, which turn out to be:
>
> 0.0145 -0.0211 -0.0005 -0.0493 2.7644
Those aren't the coefficients from p. Those are how the coefficients from p
were displayed in FORMAT SHORT, which is the default display format. Try
using FORMAT LONG G or, better yet, define:
y = p(1)*x.^4 + p(2)*x.^3 ...
and see if that looks closer to the results from POLYVAL. The portions of
the coefficients that you don't see with FORMAT SHORT are very small, but
when you're multiplying the coefficient of the quartic term by something on
the order of 2.7e42 [(4.05e10)^4]... those missing parts make a difference.
--
Steve Lord
slord@xxxxxxxxxxxxx
.
- Follow-Ups:
- Re: plotting polyfit
- From: Madiha
- Re: plotting polyfit
- References:
- plotting polyfit
- From: Madiha
- plotting polyfit
- Prev by Date: Re: Vehicle Speed
- Next by Date: Re: clear all variables but two (how to negateregular expressions: clear -regexp)
- Previous by thread: Re: plotting polyfit
- Next by thread: Re: plotting polyfit
- Index(es):
Relevant Pages
|