# Forming matrix in a simple way

``````N1(n_) := Sqrt((NN - n)*(n + 1));

N2(n_) := Sqrt(n*(NN - n + 1));

N3(n_) := ((NN - n)*(NN - n - 1)) + (n*(n - 1));

FT(n_) := J*N1(n)

ST(n_) := J*N2(n)

TT(n_) := S*N3(n)

DCnt(n_) := (-I*FT(n)*C(n + 1)) + (-I*ST(n)*C(n - 1)) + (-I*TT(n)*C(n))
``````

Write now to form a matrix using the coefficients of above relations I am using like below:

Is there a simpler code for below?

``````MatA = {{Coefficient(DCnt(0), C(0)), Coefficient(DCnt(0), C(1)),
Coefficient(DCnt(0), C(2)), Coefficient(DCnt(0), C(3)),
Coefficient(DCnt(0), C(4)), Coefficient(DCnt(0), C(5)),
Coefficient(DCnt(0), C(6)), Coefficient(DCnt(0), C(7)),
Coefficient(DCnt(0), C(8))}, {Coefficient(DCnt(1), C(0)),
Coefficient(DCnt(1), C(1)), Coefficient(DCnt(1), C(2)),
Coefficient(DCnt(1), C(3)), Coefficient(DCnt(1), C(4)),
Coefficient(DCnt(1), C(5)), Coefficient(DCnt(1), C(6)),
Coefficient(DCnt(1), C(7)),
Coefficient(DCnt(1), C(8))}, {Coefficient(DCnt(2), C(0)),
Coefficient(DCnt(2), C(1)), Coefficient(DCnt(2), C(2)),
Coefficient(DCnt(2), C(3)), Coefficient(DCnt(2), C(4)),
Coefficient(DCnt(2), C(5)), Coefficient(DCnt(2), C(6)),
Coefficient(DCnt(2), C(7)),
Coefficient(DCnt(2), C(8))}, {Coefficient(DCnt(3), C(0)),
Coefficient(DCnt(3), C(1)), Coefficient(DCnt(3), C(2)),
Coefficient(DCnt(3), C(3)), Coefficient(DCnt(3), C(4)),
Coefficient(DCnt(3), C(5)), Coefficient(DCnt(3), C(6)),
Coefficient(DCnt(3), C(7)),
Coefficient(DCnt(3), C(8))}, {Coefficient(DCnt(4), C(0)),
Coefficient(DCnt(4), C(1)), Coefficient(DCnt(4), C(2)),
Coefficient(DCnt(4), C(3)), Coefficient(DCnt(4), C(4)),
Coefficient(DCnt(4), C(5)), Coefficient(DCnt(4), C(6)),
Coefficient(DCnt(4), C(7)),
Coefficient(DCnt(4), C(8))}, {Coefficient(DCnt(5), C(0)),
Coefficient(DCnt(5), C(1)), Coefficient(DCnt(5), C(2)),
Coefficient(DCnt(5), C(3)), Coefficient(DCnt(5), C(4)),
Coefficient(DCnt(5), C(5)), Coefficient(DCnt(5), C(6)),
Coefficient(DCnt(5), C(7)),
Coefficient(DCnt(5), C(8))}, {Coefficient(DCnt(6), C(0)),
Coefficient(DCnt(6), C(1)), Coefficient(DCnt(6), C(2)),
Coefficient(DCnt(6), C(3)), Coefficient(DCnt(6), C(4)),
Coefficient(DCnt(6), C(5)), Coefficient(DCnt(6), C(6)),
Coefficient(DCnt(6), C(7)),
Coefficient(DCnt(6), C(8))}, {Coefficient(DCnt(7), C(0)),
Coefficient(DCnt(7), C(1)), Coefficient(DCnt(7), C(2)),
Coefficient(DCnt(7), C(3)), Coefficient(DCnt(7), C(4)),
Coefficient(DCnt(7), C(5)), Coefficient(DCnt(7), C(6)),
Coefficient(DCnt(7), C(7)),
Coefficient(DCnt(7), C(8))}, {Coefficient(DCnt(8), C(0)),
Coefficient(DCnt(8), C(1)), Coefficient(DCnt(8), C(2)),
Coefficient(DCnt(8), C(3)), Coefficient(DCnt(8), C(4)),
Coefficient(DCnt(8), C(5)), Coefficient(DCnt(8), C(6)),
Coefficient(DCnt(8), C(7)), Coefficient(DCnt(8), C(8))}};
``````