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 view (last 30 days)
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
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?
  1 Comment
ANINDYA GANGULY
ANINDYA GANGULY on 12 Sep 2021
Hello Image Analyst
I have worked out with the marker and colour and size constraint. But I am trying to plot the graph while imposing the charge, lone pair values and bond order of the atoms while building the cluster (connecting the indices). I would be grateful if you could help me infuse those constraints while I use the indices to build the cluster.
Thanks a ton for your valuable time and support.
Kind Regards
J

Sign in to comment.


Star Strider
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')
T1 = 4000×16 table
atom name charge no. of lone pairs id of atom atom name_1 id_1 id_2 id_3 id_4 id_5 bo_id_1 bo_id_2 bo_id_3 bo_id_4 bo_id_5 atom bond order (Sum of bo) _________ ______ _________________ __________ ___________ ____ ____ ____ ____ ____ _______ _______ _______ _______ _______ ___________________________ {'C'} -0.067 0 3994 {'C'} 3870 3996 1663 3993 0 0.952 0.948 0.949 1.064 0 3.913 {'C'} -0.175 0 3990 {'C'} 464 3989 3991 3992 0 0.956 1.176 0.956 0.957 0 4.046 {'C'} -0.157 0 398 {'C'} 1411 397 400 3944 0 0.959 0.958 0.956 0.954 0 3.827 {'C'} -0.077 0 1869 {'C'} 101 1070 837 3911 0 0.66 1.099 1.421 0.974 0 4.153 {'C'} -0.141 0 3901 {'C'} 2227 3903 2100 3902 0 0.96 0.95 0.937 1.03 0 3.877 {'C'} -0.194 0 389 {'C'} 390 391 1651 3876 0 1.047 0.958 0.952 0.97 0 3.927 {'C'} -0.164 0 2422 {'C'} 676 3320 1435 3854 0 0.954 0.959 0.945 1.062 0 3.92 {'C'} -0.264 0 3121 {'C'} 2915 2187 3703 3851 0 0.942 0.946 0.95 0.944 0 3.783 {'C'} -0.162 0 33 {'C'} 34 35 3680 3844 0 0.939 0.958 0.948 0.96 0 3.806 {'C'} -0.16 0 1034 {'C'} 2691 832 1036 3834 0 0.932 0.959 0.948 0.893 0 3.732 {'C'} -0.167 0 3829 {'C'} 2732 3832 3831 3830 0 0.966 0.939 0.953 0.953 0 3.812 {'C'} -0.289 0 3274 {'C'} 2352 1816 3276 3819 0 0.952 0.951 0.951 0.954 0 3.807 {'C'} -0.09 0 506 {'C'} 505 923 802 3811 0 1.074 0.942 0.727 0.959 0 3.702 {'C'} -0.205 0 1421 {'C'} 1808 2462 3891 3735 0 0.978 0.56 0.958 0.943 0 3.439 {'C'} -0.184 0 1810 {'C'} 1742 1048 2611 3727 0 1 0.954 0.957 0.955 0 3.866 {'C'} -0.167 0 3694 {'C'} 3693 1003 1788 3696 0 0.916 0.957 0.959 0.952 0 3.784
[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
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)?

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!