drbitboy
Lifetime Supporting Member
I can't see where you have provided a solution that runs exclusively on a PLC.
"Living is easy with eyes closed ...;" click here to see an earlier post with a solution running on an S2-1200.
That is a lot of matrix manipulation if the OP has 10 points or for a general solution for 5 to 10 points.
The number of sample points is irrelevant to the size of the problem; the matrix to satisfy OP's request of a cubic fit, equivalent to numpy.polyfit with deg=3, is always a 4x4 matrix (4x5 augmented).
We still don't know why a least squares fit is required instead of a cubic spline that goes through all the points ( knots ).
Why would we care why they prefer a cubic fit? Maybe the samples have measurement error so a cubic fit is a better model, but whatever the reason, a cubic fit is what OP asked for, and we have stated many times that Lagrange interpolation (as originally suggested by you) or a spline might be simpler, so it is up to them to choose.