I have a problem using logical arrays. I'd like to use the array for matrix element operation, for example:
I want to replace all nan elements in matrix a and replace it with b. For this example, I want output is [1, 9].
I've tried the followings:
Both give the error message "Unable to perform assignment because the left and right sides have a different number of elements."
No error message, but all elements in matrix a won't change.
I wonder if there are any ways to do it avoid using for loops (works, but slower)