-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlotClusterinResult.m
43 lines (41 loc) · 1.2 KB
/
PlotClusterinResult.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
% =================================================
% Matlab code for DBSCAN algorithm
% Written by Lab of GRC & AI
% =================================================
% Args:
% Pts: a set of points.
% minPts: a minimum number threshold parameter.
% Returns:
% IDX: cluster result
% Isnoise:
% =================================================
function PlotClusterinResult(Pts, ClusterResult)
k=max(ClusterResult); % ´ØµÄÊýÁ¿
Colors=hsv(k);
Legends = {};
for i=0:k
Xi = Pts(ClusterResult==i,:);
if i~=0
Style = '.';
MarkerSize = 8;
Color = Colors(i,:);
Legends{end+1} = ['Cluster ' num2str(i)];
else % noise, use black 'x' to mark
Style = 'x';
MarkerSize = 6;
Color = [0 0 0];
if ~isempty(Xi)
Legends{end+1} = 'Noise';
end
end
if ~isempty(Xi)
plot(Xi(:,1),Xi(:,2),Style,'MarkerSize',MarkerSize,'Color',Color,'LineWidth',2);
end
hold on;
end
hold off;
axis equal;
grid on;
legend(Legends);
% legend('Location', 'NorthEastOutside');
end