MATLAB: Populating a matrix with predetermined values

for loopif statementmatrixmatrix manipulation

I have a N x N matrix which I have defined as X, I have another matrix that contains values I would like to populate my matrix X with.
For example, if X is a 3 x 3 matrix and A is the matrix below:
A =
3 15
4 16
5 17
6 18
7 19
How do I populate the matrix X with the values in the second column of A where the first column is the position in the matrix X. i.e I would like the final matrix X to be
X = 0 0 15
16 17 18
19 0 0
Thank you.

Best Answer

X = zeros(N,N);
X(A(:,1)) = A(:,2);
X = X';