I am wondering about how to implement efficiently a code that replaces some entries of an array with specific values. In other words, I have a matrix and a vector with some indices of the matrix where a logical condition holds. I want to change these entries for some values that I have in a vector.

So far, I’ve doing it with a loop, but perhaps there is a better strategy that uses filtering or something like that.

A small example would be:

```
A = collect(1:8); println(A)
B = [10,20]
C = A.<=2
k = 1
for t=1:8
if C[t] == 1
A[t] = B[k]
k = k+1
else
end
end
```

However, I need to do this in inside a quite intensive loop, with a bigger matrix. The indices I have to change are always the same, but the vector of values (the counterpart of B) changes in each iteration.

Thanks so much!