I want to make a table to get a nbyn matrix. However, the diagonal are divided by zero. For example:
n = 5;
Table[1/(Sin[i] - Sin[j]), {i, 1., n}, {j, 1, n}]
I can use IF statement, however, is there any more elegant way to set diagonal elements to zero or any other default value?
One solution is, if the matrix is symmetric:
m = Table[0,{i,1,n},{j,1,n}];
Table[m[[i,j]] = 1/(Sin[i] - Sin[j]), {i, 1., n-1}, {j, i+1, n}]


Tablein the post should be aDo:) – Marius Ladegård Meyer May 22 '16 at 19:46Table[(1 - KroneckerDelta[i, j])/(Sin[i] - Sin[j] + KroneckerDelta[i, j]), {i, 5}, {j, 5}]. – J. M.'s missing motivation May 22 '16 at 19:52Table? – MOON May 22 '16 at 20:45Ito prevent the denumerator becomes zero accidentally. – MOON May 23 '16 at 09:37