I have a matrix A with m rows and I\'d like to set a specific element of each row equal 1. The column index varies from row to row and is specified by
A
m
I solved it using the sub2ind function:
A(sub2ind(size(A), 1:numel(a), a')) = 1