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?
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
Answers (2)
Image Analyst
on 12 Sep 2021
0 votes
scatter() and scatter3() as well as plot() all let you specify the marker color and size. Did you try any of them?
1 Comment
ANINDYA GANGULY
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
ANINDYA GANGULY
on 13 Sep 2021
ANINDYA GANGULY
on 13 Sep 2021
Star Strider
on 13 Sep 2021
My pleasure.
Carbon and hydrogen can be bonded to each other in myriad ways (from methane to others that occasonally frustrated me in my undergraduate organic chemistry courses). I would envision the ‘clusters’ as hydrocarbon molecules of various configurations. How does the ‘bond order’ define the C-C or C-H bonds in the hydrocarbon molecules?
I still have no idea what you want to do.
.
ANINDYA GANGULY
on 13 Sep 2021
Star Strider
on 13 Sep 2021
I still do not understand. I specifically do not understand how to identify the ‘clusters’ or what they mean.
Stopping here.
.
ANINDYA GANGULY
on 13 Sep 2021
Star Strider
on 13 Sep 2021
My pleasure.
I will delete my Answer, since it apparently is not what you want.
ANINDYA GANGULY
on 13 Sep 2021
Star Strider
on 13 Sep 2021
O.K., I will not delete it.
I still do not understand what ‘id_1’ ... ‘bo_id_5’ are, or what they do, so I have no idea how to use them.
.
ANINDYA GANGULY
on 13 Sep 2021
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)?
ANINDYA GANGULY
on 13 Sep 2021
Categories
Find more on Condensed Matter & Materials Physics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!