如何在Excel中创建矩阵?

huangapple go评论127阅读模式
英文:

How to create a matrix in Excel?

问题

我有一些数据,看起来有点像这样:

Value_1 Value_2 Value_3
TRUE TRUE FALSE
TRUE TRUE FALSE
TRUE FALSE TRUE

我想创建一个矩阵,统计在同一行中每个值组合被标记为true的次数。所需的输出应该像这样:

Value_1 Value_2 Value_3
Value_1 3 2 1
Value_2 2 2 0
Value_3 1 0 1

有人知道如何最好地做到这一点吗?我一直在尝试透视表,但没有成功创建符合要求的一个。

英文:

I have some data that looks a bit like this:

Value_1 Value_2 Value_3
TRUE TRUE FALSE
TRUE TRUE FALSE
TRUE FALSE TRUE

I want to create a matrix which counts the number of times each combination of two values are flagged as true on the same row. So the required output should look like this:

Value_1 Value_2 Value_3
Value_1 3 2 1
Value_2 2 2 0
Value_3 1 0 1

Does anyone know how best to do this please? I've been fiddling around with pivot tables but haven't managed to make one that works as required.

答案1

得分: 3

如果您使用动态数组公式,它将自动填充:

这只是矩阵乘法,但首先使用 --(双重否定)将 TRUEFALSE 转换为 10。以下是计算 3 的示例。

另一个选项是使用 SUMINDEX/MATCH,可以拖拽到横向和纵向。

如何在Excel中创建矩阵?

如何在Excel中创建矩阵?

如何在Excel中创建矩阵?

英文:

If you have Dynamic array formulas, this will spill:

=MMULT(--TRANSPOSE(A2:C4),--A2:C4)

如何在Excel中创建矩阵?

This is just matrix multiplication, but first the -- (double unary) converts the TRUE and FALSE to 1 and 0. Here's an example of the calculation of the 3.

如何在Excel中创建矩阵?


Another option using SUM and INDEX/MATCH that can be dragged across and down.

=SUM(INDEX($A$2:$C$4,,MATCH(F$1,$A$1:$C$1,0))*INDEX($A$2:$C$4,,MATCH($E2,$A$1:$C$1,0)))

如何在Excel中创建矩阵?

huangapple
  • 本文由 发表于 2023年6月2日 00:21:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76383907.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定