File Exchange

## Clustering by MATLAB GA tool box

version 1.0.0.0 (653 KB) by
This program creates clusters by GA tool box

4 Downloads

Updated 24 Mar 2014

View License

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

### Cite As

RMS Danaraj (2021). Clustering by MATLAB GA tool box (https://www.mathworks.com/matlabcentral/fileexchange/46008-clustering-by-matlab-ga-tool-box), MATLAB Central File Exchange. Retrieved .

### Comments and Ratings (8)

XiJack Jack

Andrii Bukata

roslan armina

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

Darshana Abeyrathna

Anurag Pujari

Great job. Thanks.

Yunhe Feng

it seems to work, thanks!

peymanstudent

hi
i want matlab code for clustering number data
tanks
email:peyman.jabraelzade@gmail.com

amir karbalaii

don work,its have 3 error

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

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!