Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有一个矩阵 A=
1 2 3; 4 5 6; 7 8 9
和一个矩阵 B=
1 NaN 3; NaN 5 6; 7 NaN NaN
我想取消在矩阵 B 中取消的相同元素。它将是:
A2=
我怎样才能做到这一点?
您可以创建新矩阵 A2 使得每个元素都是a2 = b - b + a.
a2 = b - b + a
这依赖于 NaN 通过表达式评估传播的事实,并且b - b在所有其他情况下本质上是无操作的。
b - b
它也保证永远不会溢出你的类型。