Hi there,
the following might help. I avoid using For-loops etc because it is faster.
First I generate an empty matrix of the desired dimensions:
matrix = ConstantArray[0, {9, 9, 6}];
This generates the matrix with all zeros. Let's suppose I have a couple of index combinations for which the entries are "1". I am too lazy to make some combinations up so I generate random index combinations:
nonzero = Table[{RandomInteger[{1, 9}], RandomInteger[{1, 9}], RandomInteger[{1, 6}]}, {k, 1, 10}];
Now I can populate the matrix with the "1's" at the given positions:
Set[Part[matrix, #[[1]], #[[2]], #[[3]]], 1] & /@ nonzero
I understand that this is quite different from the standard programming paradigm in say Fortran or C. If you insist in using a for loop this would work:
For[i = 1, i <= Length[nonzero], i++, matrix[[nonzero[[i, 1]], nonzero[[i, 2]], nonzero[[i, 3]]]] = 1]
Cheers,
M.