I have a matrix say
Z = [1 2 3; 4 5 6; 7 8 9]
I have to change its values, say at positions (2,2) and (3,1), to some specified v
Use sub2ind with multiple entries for rows and columns
sub2ind
Z(sub2ind(size(Z), rowNos, colNos))=0
Example:
Z = [1 2 3; 4 5 6; 7 8 9]; rowNos = [2, 3]; colNos = [2, 1]; Z(sub2ind(size(Z), rowNos, colNos))=0 Z = 1 2 3 4 0 6 0 8 9