Illustration of modifying the matrix elements:
If a single index is used with the matrix, the MATLAB unwinds the matrix column by column. For illustration, for the matrix intmat generated here, the first two elements are from the first column, and the last two are from second column:
>> intmat = randint(2,2,[0 100])
intmat =
100 77
28 14
>> intmat(1)
ans =
100
>> intmat(2)
28
>> intmat(3)
77
>> intmat(4)
14