I need to calculate polynomial coefficients in LibreOffice Calc to fit data points. X and Y values are in cells A2:... and B2:..., data size in in the cell D1, polynomial degree is in the cell D2. This works fine:
=TRANSPOSE(LINEST(OFFSET($B$2;0;0;$D$1;1);OFFSET($A$2;0;0;$D$1;1)^{1;2;3}))
I need to dynamically pass an array 1:$D$2
to this formula instead of {1;2;3}
. I've tried to use the example from Excel help:
ROW(INDIRECT("1:" & $D$2))
but it gives a value error. How to get this sequence in array?
Second question: if I'll be able to do this, how do I get the descending sequence {3;2;1;0}
?
This is due to the fact that ROW
generates a vertical array, whereas you require a horizontal array.
As such, use:
TRANSPOSE(ROW(INDIRECT("1:"&$D$2)))
Since both INDIRECT
and OFFSET
are volatile functions, I'd personally prefer:
=TRANSPOSE(LINEST($B$2:INDEX($B2:$B1048576,$D$1),$A$2:INDEX($A2:$A1048576,$D$1)^TRANSPOSE(ROW(INDEX(A:A,1):INDEX(A:A,$D$2)))))
Regards