[英]Multiply two ranges in Excel to get an array result
Excel 365 allows to multiply ranges to get an array as a result. Excel 365 允许将范围相乘得到一个数组作为结果。
Example:例子:
# # | A一种 | B乙 | C C |
---|---|---|---|
1 1个 | 1 1个 | 0 0 | 1 1个 |
2 2个 | 0 0 | 1 1个 | 1 1个 |
Entering in A3 = A1:C1 * A2:C2
输入 A3 = A1:C1 * A2:C2
will evaluate to {1,0,1} * {0,1,1}
将评估为{1,0,1} * {0,1,1}
and return an array {0,0,1}
spilling in A3:C3
并返回在A3:C3
中溢出的数组{0,0,1}
# # | A一种 | B乙 | C C |
---|---|---|---|
3 3个 | 0 0 | 0 0 | 1 1个 |
This operation can also be used in formulas, especially useful in FILTER()
, SUMPRODUCT()
etc.此操作也可用于公式,尤其适用于FILTER()
、 SUMPRODUCT()
等。
Is there a formula in Excel 365 that can take as arguments an arbitrary number of 1-D ranges, multiply them, and return a 1-D array in the same way as above? Excel 365 中是否有一个公式可以将任意数量的一维范围作为 arguments,将它们相乘,并以与上述相同的方式返回一维数组?
For what I found out so far, SUMPRODUCT()
and MMULT()
can return only a single value, not a 1-D array.到目前为止,我发现SUMPRODUCT()
和MMULT()
只能返回一个值,而不是一维数组。
Alternatively, I can write a LAMBDA
, but would like to avoid it, if there is a ready-made formula for it.或者,我可以写一个LAMBDA
,但如果有现成的公式,我想避免它。
I am not 100% what do you mean, I would assume you want to multiply all rows of the same column and return a row array with the result per column.我不是 100% 你是什么意思,我假设你想乘以同一列的所有行并返回一个行数组,每列的结果。 You can achieve it in cell E1
using the following formula:您可以使用以下公式在单元格E1
中实现它:
=BYCOL(A1:C3, LAMBDA(col, PRODUCT(col)))
and here is the output:这是 output:
If you have only positives numbers , then you can use MMULT
, based on the following mathematical properties:如果您只有正数,则可以根据以下数学属性使用MMULT
:
Putting in excel terms using EXP/LN
functions in our case it would be:在我们的例子中,使用EXP/LN
函数输入 excel 项将是:
=EXP(MMULT(TOROW(ROW(A1:C3)/ROW(A1:C3)), LN(A1:C3)))
or using LET
to avoid repetitions:或者使用LET
来避免重复:
=LET(rng, A1:C3, rows, ROW(rng), u, TOROW(rows/rows), EXP(MMULT(u, LN(rng))))
You get the same result.你得到相同的结果。
Note : rows/rows
just returns the unit vector with the same number of rows as A1:C3
.注意: rows/rows
只返回与A1:C3
行数相同的单位向量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.