From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

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!
 
 
0 Kudos
Message 1 of 3
(7,094 Views)
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


0 Kudos
Message 2 of 3
(7,082 Views)

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

0 Kudos
Message 3 of 3
(5,903 Views)