How do you cluster lines in 3D space?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Say you have the time and position of 9 samples.
A=[1:11; 1:11; 1:11];
B(1:3,1:11)=6;
C=flip(A,2);
mynoise=rand(3,11)*.75;
A=A+mynoise;
B=B+mynoise;
C=C+mynoise;
plot([A' B' C'])
How would you cluster/group these lines/paths into 3 different groups? I have been clustering at each timepoint and then connecting the cluster to the closest cluster from i-1, but that falls apart at i=6.
My real data is ankle position while walking on a treadmill. The ankle goes up/down, forward/back, in/out, and over time traces out corkscrews in x,y,z,t space. But after hundreds of steps by many subjects we have noticed some step paths are more "circular", some "triangular", and others "oval."
But I don't want to fit the data to my pre-concieved shapes, I want the data to determine the clusters. How do you cluster in x,y,z space where the clusters are linked/determined from the clusters from t-1 and t+1?
2 comentarios
Matt J
el 23 de Ag. de 2023
Editada: Matt J
el 23 de Ag. de 2023
We would have to know more about how the curves arise, and any specifics about the model they follow. Once curves intersect, there is no general way to know which post-intersection samples associate with which pre-intersection samples.
Respuestas (1)
Les Beckham
el 23 de Ag. de 2023
I would suggest something like this since the main difference in your "groups" seems to be the approximate slopes of the three groups of lines.
Of course, this may not be appropriate for your real data. If you share an example of the real data it would help in determining an appropriate approach.
A=[1:11; 1:11; 1:11];
B(1:3,1:11)=6;
C=flip(A,2);
mynoise=rand(3,11)*.75;
A=A+mynoise;
B=B+mynoise;
C=C+mynoise;
% plot([A' B' C'])
D = [A' B' C'];
plot(D)
grid on
figure
[Fx, Fy] = gradient(D);
plot(Fy)
grid on
slopes = mean(Fy, 1) % average slope of each of the 9 lines
groups = discretize(slopes, [-inf -0.5 0.5 inf]) % assign the lines to a group based on average slope
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!