Extracting some points and finding some nearest elements.
조회 수: 1 (최근 30일)
이전 댓글 표시
I have data I used dbscan clustering method. Now I need to find 5 different elements from each cluster. And calculate the 5 nearest elements of each point and group it.
In the below figure there are some points marked(pencil marked)and grouped the 5 elements(black round).
[I marked only 3 clusters just for example, I need it in the full clusters.]
After that how can I remove those clusters that do not have 5 nearest elements? Anybody, please help me.
clc;
clear;
data=xlsread('glass.xlsx');
minpts=6;
epsilon=4;
[idx, corepts] = dbscan(data,epsilon,minpts);
gscatter(data(:,1),data(:,2),idx);
댓글 수: 0
답변 (1개)
Image Analyst
2020년 3월 8일
I don't even think you need dbscan for this. You just need to define a length that separates "near enough" and "too far away". Then you just check every point in the array to see if it has 5 that are near enough, and keep those.
nearEnough = 0.02; % Whatever you want.
x = data(:,1);
y = data(:,2);
indexesToKeep = false(1, length(x)); % Initialize to not keeping any of them.
for k = 1 : length(x)
distances = sqrt((x(k) - x).^2 + (y(k) - y).^2);
if sum(distances > nearEnough) >= 5
% At least 5 are close enough to this k'th point, so keep this point.
indexesToKeep(k) = true;
end
end
x = x(indexesToKeep);
y = y(indexesToKeep);
댓글 수: 12
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!