1
$\begingroup$

For an input $n$, I have $n^2$ variables uu[1,1],...uu[1,n],...,[n,1],...,uu[n,n].

I have an equation that is linear in these (e.g. a1uu[1,1]+a2uu[2,2]+a3uu[2,2]+a4uu[1,2] .

In this case, the equation can be written as a1uu[1,1]+(a2+a3)uu[2,2]+a4uu[1,2]. I want to collect terms according to these variables, and then determine what the coefficient of each uu term is, and store these in a matrix.

I've tried putting Array[u,{n,n}] as the second argument in collect, which works when the array is one-dimensional, but doesn't work in this case.

Has anyone got a way of doing this?

$\endgroup$
0

1 Answer 1

1
$\begingroup$

I just had to write Flatten[Array[uu, {n, n}]] rather than without the Flatten. Problem solved now!

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.