I use a loop to create a set of matrixes Subscript[k[x, y], i]
, depending on variables x, y
. Then I create a large matrix
Kpr[x_, y_] = ConstantArray[0, {12, 12}];
In this matrix, using a loop, I write the values of matrices from the set in a similar way:
For[i = 1, i <= 12, i++,
Kpr[x, y][[1, 1]] =
Kpr[x, y][[1, 1]] + Subscript[k[x, y], i][[1, 1]]]`.
From this I get the message
Set::setps: Kpr[x,y] in the part assignment is not a symbol.
This means that no matrix elements are assigned.
If I set a matrix
Kpr = ConstantArray[0, {12, 12}];
without dependency on x
and y
and assign the elements of the matrix like so:
For[i = 1, i <= 12, i++,
Kpr[[1, 1]] = Kpr[[1, 1]] + Subscript[k[x, y], i][[1, 1]]]`.
matrix formation will occurs. But it is important for me to get a matrix with a dependency on x
and y
.
Code
For[i = 1, i <= 12, i++,
Subscript[k[x_, y_], i] =
{{x, y, 5 + i, 5}, {5, 4, 2 i, 0}, {x + i, 3, 5, y}, {4, 5, 3, 2}}]
Kpr[x_, y_] = ConstantArray[0, {12, 12}];
For[i = 1, i <= 12, i++,
Kpr[x, y][[1, 1]] = Kpr[x, y][[1, 1]] + Subscript[k[x, y], i][[1, 1]]]