Is there an easy way of reducing the true values in logical vector so as only one true would remain?
Example:
A = [1 2 3 4 5 6];v = [1 0 1 0 1 0];
Now I need to pick either 1, 3 or 5 from A, I don't care wich one. Insted of using find:
ind_v = find(v);Result = A(ind_v(1));
I'd like to do it more elegant, like
Result = A(FirstTrue(v));
Is there a way or should I stick with find? THX
Best Answer