06-02-2009 09:38 AM
Hi, I'm currently trying to fit a curve of only 5 points with the general polynomial fitting function but it doesn't seem to work. I tried all the algorithms and orders up to 5 (the number of points). Have you got any solution to get wonderfull fits that we get with excel ?
Solved! Go to Solution.
06-02-2009 09:52 AM
If you have N points you can fit to a polynomial of order up to N-1. When using order N-1 the polynomial should exactly go through all of the points.
Can you show your code?
06-02-2009 09:58 AM
It is possible that your data is ill conditioned.
Your x-values are offset far from zero and only cover a very small range. Have you tried to rescale x, e.g. subtract the average x from all values to see if things improve?
06-03-2009 03:08 AM
Hi, I've been an idiot, the fit was made of five points, the lines between each points was just a linear interpolation made by the software.
Now, I have a real, serious problem, still with this polynomial fitting. The fitting seem to work properly but then when I use the curve coefficients to remake the curve by my own, the curve is negative and has nothing to do with the fit. Here are pictures of the front pannel and of the block diagram of my program, have you got any solution ? I've been using as well as the curve fitting express vi, the general polynomial fitting VI but it's been doing exactly the same thing...
Thanks a lot 😉
David
Front pannel - left diagram = curve fitting that works properly & right diagram = for the same curve coefficients and X values the curve fit is way too far from the original curve to fit.
Block diagram of this part of the program
06-03-2009 04:27 AM
I think you're using the coefficients in the wrong order. If the coefficient array is a, the formula is:
y = a0 + a1*x + a2*x^2 + ...
Or as you label them, element 0 is e, element 1 is d, ...
Hope this helps,
Daniel
06-03-2009 04:52 AM
06-03-2009 09:46 AM
06-03-2009 09:55 AM
A few comments to your code. about 80% of your code in unecessary and in the style of Rube Goldberg.
Scaleability is important. Your code would need to be rewritten whenever you want a different polynomial order. If you follow my suggestion, all you need to change is the "polynomial order" input and everything else can stay as is. Try it!
If you need more detailed suggestions, please you attach your VI?