How to test if each element of a matrix is not a real number?
35 次查看（过去 30 天）
I am trying substitute for zero each element that is not a real number, without using loops. Here is a mwe:
A(~isreal(A)) = 0;
~isreal doesn't seem to test element-wise. That is, it tests the matrix as a whole: if there is a single element that is complex, then the whole matrix is tested as complex. Moreover, the substitution is performed only to the very first element. How can this be fixed?