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.
我很好奇 - 是否有一个 Matlab 命令可以返回矩阵中大于 0 的元素?
以下代码返回矩阵的所有正元素A:
A
A(find(A > 0))
或 Gunther Struyf 提出的简写形式:
A(A > 0)
find 函数将返回非零元素的索引。
ind = find(A > 0);
是你要找的...
或者专门为此目的设计的命令:'nonzeros'
nz_A = nonzeros(A);