matlab replace value in matrix -


I am trying to replace the first and second columns of an edgelist matrix (edgenumber x 3) with specific node numbers Such as:

5 1 1 1 38 1 2 1 1 28 17 1 18 1 1 25 1 1

Connection from node number (node ​​5 to node 1) The values ​​related to a vector are replaced by values. The Edgelist is generated from an unweighted 40x40 adjacency matrix. In the 40x1 size vector degree_list, there are "real" node numbers of this edgelist that I want to add to a larger 321x321 adjacency matrix. (If there is an easy way that by concatenating edgelists, it would also be great)

  degree_list = [183,150,151,39,184,185,152, ...];  

In the edgelist above, I want to change 1 1 to 2 between all 1s to 183, all 2s 150, etc.

Then I need to keep this new edgelist which I add to the big edgelist, turning it back into an adjacent matrix and my new right is big adjm.

I have tried to find a solution here and on other websites, but have not succeeded, thank you very much for your help, Chris

code

  a1 = [5 1 1 1 38 1 2 1 1 28 17 1 18 1 1 25 1 1] degree_list = [183,150,151,39,184,185,152]; Col12 = a1 (:, [1 2]) col12_uniq = unique (col12) degree_list = [degrees_list number (degrees_list) + 1: maximum (col12_uniq)] uniq_dim3 = bsxfun (@in, call 12, finite (repat (col12_uniq, 1) , 2), [3 2 1]) match_dim3 = bsxfun (@bar, uniq_dim3, permute (degree_list (col12_uniq), [3 1 2]) a1_out = [sum (match_dim3,3) a1 (:, 3)]  

Output

  a1 = 5 1 1 1 38 1 2 1 1 28 17 1 18 1 1 25 1 1 a1_out = 184 183 1 183 38 1 150 183 1 28 17 1 18 183 1 25 183 1  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -