a_matrix=zeros(10,4);a=[3 6 7 8]';for i=1:numel(a) a_matrix(a(i),i)=1;enddisp(a_matrix) 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0
MATLAB: How can i avoid the for loop in this case
for loop
Best Answer