3

For example I have a matrix

A[1,1]={1,2,3,4};

Now I want to change the second element of A[1,1] to 5,so my code is

A[1,1][[2]]=5;

but there will be some error messages.
what I want to get is

A[1,1]={1,5,3,4};

What needs to be noted in particular is that the matrix A[1,1] must have double corner mark. Because there are lots of matrix in my actual code, and I should difference them.


I came up a way to settle this. But It's a bit of tedious.

For[n = 1, n <= nt, n = n + 1, For[i = 1, i <= it, i = i + 1, A[n, i] = Array[a[n, i], 4]]]

In this example

a[1,1][1]=1;a[1,1][2]=2;a[1,1][3]=3;a[1,1][4]=4;
a[1,1][2]=5;

Then I can get the A[1,1]={1,5,3,4};And I can handle the matrix with any corner mark.

郑新然
  • 47
  • 4

1 Answers1

7

Have a look at ReplacePart[]

A[1, 1] = {1, 2, 3, 4};
ReplacePart[A[1, 1], 2 -> 5]
{1, 5, 3, 4}
infinitezero
  • 1,419
  • 8
  • 18