⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 showclusters.m

📁 这个是支持向量聚类机用matlab编译的主程序和部分子程序
💻 M
字号:

%=====================================================================
%
%   ShowClusters
%   ----------------
%
%   Parameters:   
%		Samples         - This matrix holds the data points.
%		clusters_assignments -
%		        A vector of the clusters assignments assigned by the algorithm 
%		        to the data points.
%       attr1, attr2    - The dimensions of the current 2D space.
%
%	Presents graph showing the different clusters.
%
%=====================================================================


function [] = ShowClusters(Samples,clusters_assignments,attr1,attr2)


nof_clusters = max(clusters_assignments);
color_vector = zeros(1,3);

figure;
% iterates over all the clusters.
for i = 1:nof_clusters
    cur_cluster = find(clusters_assignments == i);
    % assigns a color for the cluster (totally 7 colors)
    color = dec2bin(mod(i-1,7),3);
    color_vector(1)= str2num(color(1));
    color_vector(2)= str2num(color(2));
    color_vector(3)= str2num(color(3));
    
    hold on;
    % showing the current cluster
    plot(Samples(1,cur_cluster),Samples(2,cur_cluster),'+','color',color_vector);

end

title(strcat('The Clusters in 2D space - Dimension:',num2str(attr1),' and:',num2str(attr2))); 
xlabel(strcat('Attribute: ',num2str(attr1))); 
ylabel(strcat('Attribute: ',num2str(attr2))); 

hold off;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -