04-07-2009 08:58 AM
Hello.
I need to create calibration curve by fitting experimental points by the 3-order polynom. I tried it with General Polynom Fit.vi (see attachment). The very strange thing is that the resulting curve doesn't pass through the Best Polynomial Fit points. Please, take a look at my code, maybe I missed something?
Solved! Go to Solution.
04-07-2009 09:35 AM
The polynomial fit is working correctly. The problem is the code in the formula node. I remember reading threads about errors using the "^" operator in formula nodes - you can do a search to find discussions on this. Besides, you don't even need to use the formula node. Simply numeric functions are polymorphic and will work with arrays. Also, the Index Array function is resizable. See attached.
TiP: Don't know where you cal data is coming from, but if you had it as a 2D array then you wouldn't need that first element, and you would need just one Index Array function to get the X and Y arrays.
04-07-2009 10:54 AM - edited 04-07-2009 10:56 AM
smercurio_fc wrote:Besides, you don't even need to use the formula node.
We also don't need the explicit polynomial calculation. Simply use the polynomial evaluation from the polynomial palette. (see image)
The nice thing is that no code changes are needed if you later decide to do a higher (or lower) order fit instead. This solution is much more scalable. 😄
Make the polynomial order a control and you can change it on the fly. 😉

04-07-2009 11:12 AM - edited 04-07-2009 11:14 AM
altenbach wrote:
smercurio_fc wrote:Besides, you don't even need to use the formula node.
We also don't need the explicit polynomial calculation. Simply use the polynomial evaluation from the polynomial palette. (see image)
 Of course. There was a good reason why I did it that way. The intent of my mod wasn't to point the user to a "magic" function, but to show that the numeric functions are polymorphic and can therefore handle array/scalar calculations without having to resort to the formula node crutch. 
  Based on the code I suspect the user has a background in text-based programming. 
One can also use the Ramp function to generate the array of X values rather than the loop.