MATLAB: What wrong with the indexing code

indexingMATLAB

If I want to fill in a matrix, of which I have its indices without a for loop, how could I do it? Suppose that the (row(i),col(i)) elements to be filled are given.
value = 189;
row = [ 1 3 6 7 8 ];
col = [ 1 1 4 4 5];
B(row,col) = value

Best Answer

B = full( sparse(row, col, value) );
or
B = accumarray([row(:), col(:)], value);