Can anyone explain how the following code:
Y(Y==0) = -1
sets all values of 0 to -1. For example for:
Y = [1 1 1 0 0 0 1]
we get:
Y = [1 1 1 -1 -1 -1 1]
What is confusing me is that Y==0 does not return a vector of indices.
An if I try to use the vector Y==0 directly I get the error:
Y([0 0 0 1 1 1 0]) = -1
error: subscript indices must be either positive integers or logicals
I would have naturally opted for:
Y(find(Y==0)) = -1
and would like to know why the above does not use find
TIA