I'm new to Mathematica and I'm trying to work with Do
for a set of indexed objects in order to avoid doing the same action repeatedly. For example, I create the following lists:
dog[1] = {{1, 1}, {5, 7}, {3, 10}};
dog[2] = {{7, 2}, {11, 8}, {4, 3}};
dog[3] = {{1, 7}, {1, 5}, {9, 3}};
And I want to change the value of the second columns on each of these 10 times. My approach to the problem:
Do[Part[dog[i], All, 2] = 10*Part[Perro[i], All, 2], {i, 3}]
But it returns me the error: dog[i] in the part assignment is not a symbol.
How can this be fixed? I would really appreciate your help.
dog = ConstantArray[{{1, 1}, {2, 1}, {3, 1}}, 3]
. $\endgroup$dog
a function? It looks to me that you wantdog
to be a vector. To access vector components, you need double square brackets[[]]
. If it's a function, I don't think you can assign to a part of it. $\endgroup$