testkmean.m
来自「K-mean 模式識別分析法使用k-mean作為分析方法」· M 代码 · 共 29 行
M
29 行
clear all
close all
clc
load('\data.mat')
k=4;
%%%%%%%%%%%%%%%%%%%%%
% Funcion k-means %
%%%%%%%%%%%%%%%%%%%%%
[center, Xcluster, Ycluster, clustering]=kmean(X, Y, k);
% Presentation of results per screen.
% Create the colors.
color=zeros(k,3);
for i=1:k
color(i,:)=rand(1,3);
end;
% Represent information.
figure;
hold on;
for i=1:k,
n=find(clustering==i);
p=plot(X(n), Y(n),'.');
set(p,'Color',color(i,:));
title(['Number of clusters: ',num2str(k)])
end;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?