I want to link data points based on ids (which are linked numerically) and then make clusters; finally deriving all the clusters + know each cluster size?
5 ビュー (過去 30 日間)
古いコメントを表示
ANINDYA GANGULY
2021 年 9 月 10 日
コメント済み: ANINDYA GANGULY
2021 年 9 月 11 日
Since I am new to matlab, I am noob on coding; Could some one help me figure out a code when using the ids it would feasible to build clusters and stop when a cluster is built and start a new cluster and so on...
I have attached the input file for your reference.
Thanks in advance
J
0 件のコメント
採用された回答
Walter Roberson
2021 年 9 月 10 日
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/734224/Test%20file.xlsx';
T = readtable(filename, 'VariableNamingRule', 'preserve');
ns = T.id; nd = T.id_1;
mask = nd ~= 0;
s = ns(mask); d = nd(mask);
nd = T.id_2;
mask = nd ~= 0;
s = [s; ns(mask)]; d = [d; nd(mask)];
nd = T.id_3;
mask = nd ~= 0;
s = [s; ns(mask)]; d = [d; nd(mask)];
nd = T.id_4;
mask = nd ~= 0;
s = [s; ns(mask)]; d = [d; nd(mask)];
G = graph(s, d);
plot(G)
bins = conncomp(G);
The bins can be analyzed to extract the connected components. At the moment I do not know of any nice way of doing that.
5 件のコメント
Walter Roberson
2021 年 9 月 11 日
If coordinates are available, then the graph() object plot() method can be told to use them.
I am not sure what you mean about color codes? Do you mean that you want atoms to be colored according to their type, or do you mean that you want each molecule to be a different color than the other molecules ?
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!