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.
如何在条件下迭代矩阵并更改值..例如:我有大小为 100x100 的矩阵 m,我在做:
m(m<10)=func(elemnt);
element 应该是迭代时的当前元素。我如何访问当前元素?
尝试简单 m(m<10)=func(m(m<10));
m(m<10)=func(m(m<10));
例子:
m=[[1 2 3];[5 6 7];[8 9 10]] m = 1 2 3 5 6 7 8 9 10 m(mod(m,3)==2) = m(mod(m,3)==2) * 5 m = 1 10 3 25 6 7 40 9 10
唯一的限制是您的自定义函数可以处理向量。