MATLAB Answers

I need help grouping randomly oriented platelets into stacks using two different criteria.

1 view (last 30 days)
Jonathan Salazar
Jonathan Salazar on 16 Aug 2017
Answered: Neil Guertin on 22 Aug 2017
I am given a box full of platelets that are randomly oriented. I need to group the platelets by stacks. the criteria for staking is 1) that the distance between their midpoints is below a certain threshold(I am working on finding this value) and 2) that the absolute value of the scalar product between two of the normal vectors of the platelets is greater that .95. I have already written the code for finding the midpoint of each platelet and the normal vector of each platelet. what I am struggling with is actually grouping them together based on this criteria. i tried using D = squareform(pdist(platelet)) for the first criteria but i do not know how to get the information i need from the output. Thank you!
for k = 1 : num_tags % num_tags == number of platlets
platelet = find(mol_tag1 == unique_mol_tags(k));% groups atoms into platlets
xmid = mean(x(platelet));
ymid = mean(y(platelet));%takes mean of x,y,z coordinates in each platlet to find midpoint
zmid = mean(z(platelet));
midplat(k,:) = [xmid,ymid,zmid];% midpoint of each platlet
D = squareform(pdist(midplat));

Answers (1)

Neil Guertin
Neil Guertin on 22 Aug 2017
Each platelet's location can be represented by a 1x6 vector, with the first three entries representing position as you have done, and the next three representing orientation as given by the normal vector.
You will then need to write a custom distance function. This should give the euclidean distance as usual for platelets in the same orientation, but give inf for platelets with different orientations. Read the documentation to make sure you are implementing this function correctly as it must accept a matrix representing multiple points as its second argument.
pdist just calculates the distances between points. To group them into clusters you will need to use the cluster and linkage functions.
X = [platelet_midpoints platelet_norms];
Z = linkage(X,method,@distance_function);
T = cluster(Z,'cutoff',n);

Community Treasure Hunt

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

Start Hunting!

Translated by