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=[2 3 4; 6 1 2]
私は2つの最大の要素を見つけて、他のすべての要素をゼロにしたい. この場合、Aは最終的に
A=[0 0 4; 6 0 0]
>> A=[2 3 4; 6 1 2] A = 2 3 4 6 1 2 >> [~,idx] = sort(A(:), 'descend'); >> A(idx(3:end))=0 A = 0 0 4 6 0 0