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.
我有一个包含 2 个值的矩阵,例如:
[ 1 1 1 1 1 0 0 0 1 1 0 0 0 0 0 0 0 1 1 1 1 0 0 0 1 1 ]
我想将一行中的所有其他元素从“1”更改为 0,因此输出将是:
[ 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 ]
如果您的矩阵是,m那么您可以执行以下操作:
m
ind=find(m(:)==1); m(ind(1:2:end))=0;