简体   繁体   English

数组作为单元格公式参数

[英]Array as cell formula parameter

I need to calculate polynomial coefficients in LibreOffice Calc to fit data points. 我需要在LibreOffice Calc中计算多项式系数以适合数据点。 X and Y values are in cells A2:... and B2:..., data size in in the cell D1, polynomial degree is in the cell D2. X和Y值在单元格A2:...和B2:...中,数据大小在单元格D1中,多项式在单元格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} . 我需要将一个数组1:$D$2动态传递给该公式,而不是{1;2;3} I've tried to use the example from Excel help: 我尝试使用Excel帮助中的示例:

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} ? 第二个问题:如果我能够做到这一点,如何获得降序{3;2;1;0}

This is due to the fact that ROW generates a vertical array, whereas you require a horizontal array. 这是由于ROW生成垂直数组,而您需要水平数组。

As such, use: 因此,请使用:

TRANSPOSE(ROW(INDIRECT("1:"&$D$2)))

Since both INDIRECT and OFFSET are volatile functions, I'd personally prefer: 由于INDIRECTOFFSET都是易失函数,因此我个人更希望:

=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 问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM