How to find number of counts for atoms (each minor grid) within XY grid?

1 Ansicht (letzte 30 Tage)
Hello everyone, I have ID, type and XYZ coordinates of atoms within a box (as attached 1_aniline_epoxy_inftrated_ID_type_XYZ_data.txt data and image). Box is transformed in to number of XY grids or rectangle. I want to count number of atoms belong to each rectangle and want to plot number of counts into XY plot. Data and figure is attached.
Thank you,
Ankit

Akzeptierte Antwort

Star Strider
Star Strider am 6 Jan. 2023
I am not certain what you want.
The histogram2 function is one option —
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1254562/1_aniline_epoxy_inftrated_ID_type_XYZ_data.txt');
T1.Properties.VariableNames = {'ID','Type','X','Y','Z'}
T1 = 894×5 table
ID Type X Y Z ____ ____ ______ ______ ______ 16 1 14.034 26.858 38.603 17 1 12.782 27.304 38.207 18 6 12.464 27.735 36.763 19 4 15.1 27.81 38.712 20 3 12.451 28.809 36.614 21 3 14.629 28.605 36.936 22 7 15.016 29.049 37.842 24 3 13.163 27.348 36.031 26 3 11.472 27.435 36.445 27 3 10.355 28.576 38.771 29 3 14.2 29.576 38.323 1205 1 14.222 25.673 39.358 1206 1 11.653 27.171 39.178 1207 7 15.489 24.793 39.285 1208 3 15.254 23.731 39.318 1209 4 10.535 27.833 39.429
figure
scatter3(T1.X, T1.Y, T1.Z, 15, T1.Type, 'filled')
xlabel('X')
ylabel('Y')
zlabel('Z')
title('3D Scatterplot Of Data')
axis('equal')
colormap(turbo(numel(unique(T1.Type))))
title('3D Scatterplot Of Data')
figure
hh3 = histogram2(T1.X, T1.Y, 10);
hh3.FaceColor = 'flat';
colormap(turbo)
xlabel('X')
ylabel('Y')
zlabel('Z')
title('2D Histogram Of Data')
gethh3 = get(hh3); % Handle To Function
% Vals = hh3.Values % Same Matrix As 'Counts' Here
Counts = hh3.BinCounts
Counts = 10×10
1 6 4 4 7 3 2 2 1 3 2 17 18 9 7 11 17 15 11 9 1 10 10 11 7 17 14 17 10 13 4 12 15 5 10 12 14 11 5 6 1 19 10 8 9 10 15 14 8 9 5 17 9 13 9 14 18 20 8 5 5 6 11 9 11 10 13 13 17 11 1 5 12 1 2 6 10 12 10 13 3 11 8 7 10 15 12 14 10 4 1 7 3 7 6 8 3 8 3 2
.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by