I want to replace elements 10-20 of a vector with 0's. I'm wondering why the following didn't work:
vect = Table[1, {100}] Do[ReplacePart[vect, i->0], {i, 10, 20, 1}]
The resulting vector is still composed entirely of 1's. I'm using Mathematica 8.
This one here is very direct:
Do[vect[[i]] = 0, {i, 10, 20}]
Cheers,
M.
This also works
ReplacePart[vect, Table[i -> 0, {i, 10, 20}]]
Hi,
I think that this is because MMA does the substitution but you do not save that in the vector again. This works:
Do[vect = ReplacePart[vect, j -> 0], {j, 10, 20}]