Re: plotting polyfit




"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


.



Relevant Pages

  • RE: How do I adjust a curve ?
    ... I do the change in the format on the displayed equation and you have reason. ... polynomial coefficients are from LINESTin Excel versions prior to 2003. ... The plot of the experimental data is like the nromal distribution, ...
    (microsoft.public.excel.charting)
  • Re: plotting polyfit
    ... but still, the same, consistent wrong plot. ... You're right in that the portions of the coefficients matter... ... desired plot should have a y-axis range from 1 to 4 with a decreasing ... > were displayed in FORMAT SHORT, ...
    (comp.soft-sys.matlab)
  • Help with VPA, digits and precision in a variable ...
    ... among the coefficients are giantic in some cases, therefore, ... which is not able to plot. ... then it again reduced the digits of the number to defaults ... format (if i use format long reduces to 15 and otherwise to ...
    (comp.soft-sys.matlab)
  • Re: Quantization of fixed point filter coefficients.
    ... using a Q1.15 format. ... This range cannot represent the coefficients b1 ... intermediate results but it will not overflow overall. ... Whatever else you do you will end up having to scale the input signal. ...
    (comp.dsp)
  • Re: Assembly Process for FE (Finite Element) code in C
    ... encountered some problems in assembly stage. ... I think the preferred storage format for the ... arrays as each local stiffness matrix is calculated in the loop. ... That is a 2D problem so for each unknown equation in the matrix I have to look left, right, up and down in order to take boundary effects in consideration (my first and last cell doesn't have as many coefficients as the interior cells - actually that applies to all cells on the domain boundaries). ...
    (comp.lang.c)