Let's say I have a vector b where each row correspond to an index for each row in the matrix A. I want to assign 1 to these elements, like in the matrix C, without loops. Thank you
A = zeros(4,3);b = [2;1;2;3];C = [0 1 0; 1 0 0; 0 1 0; 0 0 1]
indexmatrix
A = zeros(4,3);b = [2;1;2;3];C = [0 1 0; 1 0 0; 0 1 0; 0 0 1]
Best Answer