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 矩阵中选择一些值大于 4 的数字并将它们设置为零。
例如:
A=[5 6 1 3 4 9 2 8 3];
现在,用零替换所有大于 4 的值并存储为新矩阵 A1:
A1=[0 0 1 3 4 0 2 0 3];
您可能想尝试这样的事情:
A(A>4)=0
这里是:
>> A=[5 6 1 3 4 9 2 8 3] A = 5 6 1 3 4 9 2 8 3 >> A(A>4)=0 A = 0 0 1 3 4 0 2 0 3