How to code and build a smaller array and 2D-plot charged particles to make clusters (as they are linked via indices) using charge, no of lone pair of electrons & bond order?
1 次查看(过去 30 天)
显示 更早的评论
In the worksheet I have provided the indices and the charge and the lone pair of electrons' values alongwith with the specific bond order values which are obtained for that particular atom (C/H) as it interacts with other C's and H's to build clusters. Is there a code to plot these on a 2D/3D where we can colour code the clusters and change the sizes of the particular cluster and so on.
It's a 4000 x 16 matrix.
I have attached the file for your reference.
Regards
J
0 个评论
回答(2 个)
Image Analyst
2021-9-12
scatter() and scatter3() as well as plot() all let you specify the marker color and size. Did you try any of them?
Star Strider
2021-9-12
I am not certain what you want. I have no idea what ‘collecting the indices’ implies.
Try this —
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/735859/Testfile4.xlsx', 'VariableNamingRule','preserve')
[G,ID] = findgroups(T1.('atom name')); % Atom Name Groups
Lv = G==1;
% sv = (G==1).*12 + (G==2).*1;
% cv = (G==1)*[1 0 0] + (G==2).*[0 0 1];
figure
hs(1) = scatter3(T1.charge(Lv), T1.('no. of lone pairs')(Lv), T1.('atom bond order (Sum of bo)')(Lv), 12, 'r', 'filled');
hold on
hs(2) = scatter3(T1.charge(~Lv), T1.('no. of lone pairs')(~Lv), T1.('atom bond order (Sum of bo)')(~Lv), 2, 'b', 'filled');
hold off
grid on
xlabel('Charge')
ylabel('Number Of Lone Pairs')
zlabel('Atom Bond Order')
legend(ID, 'Location','best');
Breaking the scatter3 plots into two separate calls is necessary for the legend to work correctly to identify both elements.
.
12 个评论
Image Analyst
2021-9-13
编辑:Image Analyst
2021-9-13
For convenience, so we can see it here instead of opening a new, second instance of MATLAB for just that figure, could you attach the screenshot (save it as a PNG image file then use the frame icon to insert it, like Star did in his answer)?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Directed Graphs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!