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?
2 views (last 30 days)
Show older comments
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 Comments
Answers (2)
Image Analyst
on 12 Sep 2021
scatter() and scatter3() as well as plot() all let you specify the marker color and size. Did you try any of them?
Star Strider
on 12 Sep 2021
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 Comments
Image Analyst
on 13 Sep 2021
Edited: Image Analyst
on 13 Sep 2021
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)?
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!