I've the following dataset:
node1 = 12341node2 = 23457cost = 23 for arc(1,2) # arc is a combination of node1 and node2 14 for arc(2,3)123 for arc(3,4)111 for arc(4,5)60 for arc(1,7)
I would like to create a nxm matrix say C with rows and columns being the maximum of (nodes1,nodes2)(in this case it would be 7 so it would be a 7×7 matrix) such that C will have the values of the column vector 'cost' for its respective arcs ( arc is connection between elements of node1 and node2) otherwise it would have a value 0. So my resulting matrix should look like this:
[0 23 0 0 0 0 60;23 0 14 0 0 0 0;0 14 0 123 0 0 0;0 0 123 0 111 0;0 0 0 111 0 0 0;0 0 0 0 0 0 0;60 0 0 0 0 0 0]I am not sure I can do this using matlab. Please help.
Best Answer