File Exchange

## Clustering by MATLAB GA tool box

version 1.0.0.0 (653 KB) by RMS Danaraj

### RMS Danaraj (view profile)

This program creates clusters by GA tool box

Updated 24 Mar 2014

unzip the folder 'mk'and run test1.m which clusters random sample od 10,000 two dimension data into 5 clusters by K emans algorithm.
*************
clear;
clc;
% x is the vector of centroids of the cluser gropr. x(1),x(2) coordinates
% of first cluster and so on.so if no of clusters id k the dimension of x
% is 2*k
data=rand(10000,2);
% random data to be grouped as clusters
k=5;
save data
save k
options = gaoptimset('PopulationSize', 50,'Generations', 500,'StallGenLimit',500,'TimeLimit', 2000,'StallTimeLimit', 2000,'PlotFcns', {@gaplotbestf,@gaplotbestindiv});
[x F]=ga(@clust1,2*k,options)
% x=rand(1,10);
[F s1]=clust1(x);
pause;
close('Genetic Algorithm')
aa1=find(s1==1);
x1=data(aa1',1);
y1=data(aa1',2);
aa2=find(s1==2);
x2=data(aa2',1);
y2=data(aa2',2);
aa3=find(s1==3);
x3=data(aa3',1);
y3=data(aa3',2);
aa4=find(s1==4);
x4=data(aa4',1);
y4=data(aa4',2);
aa5=find(s1==5);
x5=data(aa5',1);
y5=data(aa5',2);
cx1=x([1 3 5 7 9]);
cy1=x([1 3 5 7 9]+1);
plot(x1,y1,'*',x2,y2,'+ ',x3,y3,'s ',x4,y4,'. ',x5,y5,'v ');
hold on
plot(cx1,cy1,'kd');
% each cluster is chown is different colors and symbols, the centroids are pointed as dimond

XiJack Jack

Andrii Bukata

roslan armina

### roslan armina (view profile)

can this algorithm use for my own data such as i want to use for breast cancer data

Darshana Abeyrathna

Anurag Pujari

### Anurag Pujari (view profile)

Great job. Thanks.

Yunhe Feng

### Yunhe Feng (view profile)

it seems to work, thanks!

peymanstudent

### peymanstudent (view profile)

hi
i want matlab code for clustering number data
tanks

amir karbalaii

### amir karbalaii (view profile)

don work,its have 3 error

##### MATLAB Release Compatibility
Created with R14SP3
Compatible with any release
##### Platform Compatibility
Windows macOS Linux