I want to create a n
by n
Identity matrix and replace the ones with n π^2
. NOS
is three here (it is a number). The code I have written for this doesn't work.
Kin = IdentityMatrix[NOS]
n = 1; m = 1; While[n == m && n < NOS && m < NOS,
Kin[[n, m]] -> n π^2; n++; m++]
I want
Kin[[1, 1]]== π^2
Kin[[2, 2]]==2 π^2
and so on. Could anyone help me with this please?
Pi^2 DiagonalMatrix[Range[NOS]]
$\endgroup$