Sunday, April 26, 2020

Generate a Matrix

Hi all,

I am having a problem generating a matrix from data. Suppose I have a dataset like this
i j x
1 3 5
2 2 2
3 1 6
I want to generate a 3*3 matrix A, where (i, j)-th element is the value of x based on the above table. So the output looks like
0 0 5
0 2 0
6 0 0
How can I achieve this?

Thanks a lot!

No comments:

Post a Comment