I have a logical matrix MASK and a vector VEC with real numbers (uint8 mostly). nnz(MASK) equals length(VEC).
I create a new matrix NEW where the logical 1's in MASK are replaced by the values in VEC--in sequential order:
NEW = MASK; NEW(NEW>0) = VEC;
Can I do this with 1 statement? Because in practice I want to replace NEW with VEC since I dont need VEC anymore after the operation, and don't want to pile up variables. MASK should remain untouched.