Consider an altered example:
In a 3x5 array, assign a fixed value to elements (3,3), (2,5), and (1,1)
A(sub2ind(sz,[3 2 1],[3 5 1])) = 37
This uses linear indexing to do the job. In order to calculate the indices, sub2ind() is used to convert the row and column subscripts specified in the two vectors. Linear indices are calculated column-major, so the indices for this example would be [9 14 1].