Hello,
My question is very primitive, I'm trying to cluster my dataset using k-means and plot clastered data in heatmap.
I've tried to write the following primitive code but I don't understand why it is not working. Could you please help me figure out why my code is not working and what would be the shortest way to do this simple clustering?
Thank you!
n = 3; % specify the number of clusters that you want the dataset to be divided into
data = randi(100,10,9); clust_idx = kmeans(data,n);clustered = [];for j = 1:n for i = 1:length(clust_idx) if clust_idx(i)==j, clustered = [clustered, (data(:,i))]; end endendf = figure(1);fh = heatmap((clustered)','XLabel','Time(min)','YLabel','Cell #','Colormap',jet);
Best Answer