2

Imagine I have several (i.e. > 100) column vectors of numbers. Vectors are large with equal length (e.g. 20k items). The vectors are not adjacent, so they don't make a matrix.

What I want, is to get some row-wise computation with the vectors, for instance

For each row what is the first non zero value among all vectors?

or

For each row what is the maximal value among all vectors?

See this simplified example, that should get the maximal value for all vectors, which would be 3 for all row (in reality the displayed value is 1):

enter image description here

It would be easy, if I could copy the vectors as a matrix and get the column of row ranges that spans all vectors for a given row, instead of the column ranges. But that is not the option due to the size of the data. I think it is related to other SO question: Is it possible to have array as an argument to INDIRECT(), so INDIRECT() returns array?.

4

2 回答 2

2

您可以使用 CHOOSE 将大小相等的列组合成一个范围,例如,对于您的 3 范围示例:

=CHOOSE({1,2,3},$B$1:$B$4,$B$5:$B$8,$A$3:$A$6)

然后直接在公式中使用它,例如在 G2 中复制下来以获取每行中的 MAX 作为您的示例

=MAX(INDEX(CHOOSE({1,2,3},$B$1:$B$4,$B$5:$B$8,$A$3:$A$6),F2,0))

或者您可以将 CHOOSE 部分定义为命名范围[如果您有 100 个范围特别有用],例如命名 Matrix 并使用

=MAX(INDEX(Matrix,F2,0))

您需要根据范围数修改 {1,2,3} 部分,以便在您有 100 个范围时可以使用快捷方式

=CHOOSE(TRANSPOSE(ROW(INDIRECT("1:100"))),Range1, Range2.....Range100)

现在需要用CTRL++SHIFT确认ENTER

要获得第一个非零值,您可以使用此版本

=INDEX(INDEX(Matrix,F2,0),MATCH(TRUE,INDEX(Matrix,F2,0)<>0,0))

也用CTRL+ SHIFT+确认ENTER

于 2013-11-05T16:45:44.940 回答
-1

我发现您实际上“可以”从INDIRECT().

但是它必须在"R1C1"语法中,并且您不能使用公式创建 R1C1 语法(而不是使用"R" & ROW() & "C" & COLUMN()".

您必须输入 ROW & COLUMN 数字作为绝对数字,然后它才能工作。

{}显然,当它们由ROW()or函数返回时, excel 会将数字放在周围COLUMN(),我想这就是它不起作用的原因(尝试调试,你会看到)。

于 2018-09-09T15:21:00.480 回答