Clustering by MATLAB GA tool box
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 (2025). Clustering by MATLAB GA tool box (https://www.mathworks.com/matlabcentral/fileexchange/46008-clustering-by-matlab-ga-tool-box), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- Industries > Biotech and Pharmaceutical > Genomics and Next Generation Sequencing >
- Mathematics and Optimization > Optimization Toolbox > Quadratic Programming and Cone Programming >
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
MK/
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 |