LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Polynomial Interpolation.vi not functioning properly

I have a VI that demonstrates an unexpected behavior with the Polynomial Interpolation.vi. It seems that with certain data sets (this one is quite linear), the interpolation blows up, and returns huge numbers. When I run the standard Interpolat 1D Array native, I get a result that makes sense. I would like to use the Polynomial Interpolation VI because of its extrapolation capabilities. However, I can't use it even for interpolation. What am I doing wrong? Is this a bug?
 
Here's the VI (with data saved as default) demonstrating this strange behavior (LV 8.0.1).
 
thanks.
 
Message 1 of 4
(3,035 Views)
I am not an expert in interpolation, but I suspect that the problem is that your data is close to a straight line. The help file for the Polynomial Interpolation.VI says, "The VI calculates output interpolation value P[n – 1](x), where P[n – 1] is the unique polynomial of degree n – 1 that passes through the n points (x[i]y[i])." If it finds a 704th order polynomial (you have 704 data points), it may have some extreme values at points not very close to one of the specified input points.

While polynomial interpolation can be used for extrapolation, be careful about the behavior of the polynomial outside the limits of the origianl data. Fitted polynomials tend to large values rapidly for x values not within the range of the xi. The Polyomial Interpolation.VI does not return the polynomial or its coefficients so you cannot be sure of what it is doing.

Lynn
0 Kudos
Message 2 of 4
(3,030 Views)
Thanks, Lynn. That makes sense, I should have read the help closer. Since I'm really only concerned about linear fitting right now, I'll just write my own function using the linear fit coefficients.
 
-scott
0 Kudos
Message 3 of 4
(3,024 Views)

Well, instead of using "Polynomail interpolation", you could first fit a linear function to the data, obtain the slop and intercept coefficients and, after that, you can evaluate the polynomial ax+b directly. LabVIEW 8 has "Evaluate Polynomial" that, after given polynomial coefficient, you can obtain the desired result and Linear Fit will obtain the coefficients. The best thing about this solution is that you can extrapolate the data while the "interpolate 1D array" stay at the maximum.

 The example is in attachment. Hope this helps!

Barp - Control, Simulation, RTT and HIL - National Instruments
0 Kudos
Message 4 of 4
(3,012 Views)