B = [1,9,12,31];
C = [1,4;3,6;5,2;6,3]
A = zeros(6,6);
% assign those values:
X = sub2ind(size(A),C(:,1),C(:,2));
A(X) = B
For comparison:
[0 0 0 1 0 0; 0 0 0 0 0 0; 0 0 0 0 0 9;0 0 0 0 0 0; 0 12 0 0 0 0;0 0 31 0 0 0]
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!