How do you cluster lines in 3D space?
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Les Beckham
2023-8-23
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!