10-02-2017 11:50 AM
10-02-2017 11:58 AM - edited 10-03-2017 10:36 AM
Not if you use a 3rd order polynomial. You data does not look at all like the fit, so what's the purpose of all this? You can always fit to an arbitrary nonlinear model that has the desired limiting conditions.
10-03-2017 04:16 AM
Altenbach thanks for the reply. We need to know the trend of the curve for later calculations so we use a polynomial of third order, because for the great majority of data this function is correct. I attached you a ".vi" so you can see an example of signals that I am processing. In each of them I have added the best interpolation from my point of view.
10-03-2017 10:45 AM
As a first step, stop using express VIs, they are clunky. Use general polynomial fit. You also don't need all that duplicate code. Use a single instance of the code and a FOR loop.
There is a "weight" input, so all you need to do is give the first and last point a much higher weight and the algorithm will try to force the fitted curve closer through these points, at the expense of the other points.
10-03-2017 11:40 AM
Thanks Altenbach,
10-03-2017 11:50 AM
Sorry,
10-03-2017 01:32 PM - edited 10-03-2017 03:42 PM
You have a couple of bugs, for example the last element has index N-1, not N. You are not modifying the right side of the weight array at all.
Here's what I had in mind. Seems to work quite well.
If you want the edge points even closer to the data, increase their weight even more (e.g. 1M).