NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
Steverino
Posts: 125
0 Kudos

How are coefficients returned when using the CWStat Polyfit function?

I am trying to extract the coefficients returned by the "Polyfit" function.
 
For example, I am trying to fit a 2nd order polynomial equation to a set of points. The Coef variant returns 3 values.
 
Which one is the coefficient for x2, x, and offset?
 
Thanks!
 
 
Member
Andrew W
Posts: 62
0 Kudos

Re: How are coefficients returned when using the CWStat Polyfit function?

Howdy Steverino -

Keeping the prototype in mind:
CWStat.PolyFit x, y, Order, z, Coef, mse

Coef is an output (variant type) of one-dimensional array of polynomial coefficients.

Therefore, the first element in Coef is your offset, second element in Coef is x, third element is x2.

For more information on the PolyFit function, as well as an example, consult the "Measurement Studio Reference" (usually found in Start Menu>>Program Files>>National Instruments>>Measurement Studio>>Help>>Measurement Studio Help).

Have a great day!

Andrew W || Applications Engineer
National Instruments


Member
jmevans
Posts: 25
0 Kudos

Re: How are coefficients returned when using the CWStat Polyfit function?

Andrew,

 

Regarding your statement: "Therefore, the first element in Coef is your offset, second element in Coef is x, third element is x2."

 

I trust your information, but the order of returned coeficients does not follow from the prototype. And this does not seem to be documented anywhere, either in the Reference Manual or in the examples.

 

So, for an example, a PolyFit of order 3 (AX^3 + BX^2 + CX + D) returns the coefficients as:

coef[0] = D

coef[1] = C

coef[2] = B

coef[3] = A

 

Is this correct? It seeme very counter-intuitive!

 

Thanks!

 

Jesse

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page