MATLAB: I have this scrip, can somebody explain to me about the last line

clusteringkmeansStatistics and Machine Learning Toolbox

[m D.^0.5]

Best Answer

m indicate the cluster index number corresponding to rows in data. D represent the distance of data points from cluster Centroid. D.^0.5 is used because by default kmeans() returns square of the Euclidean distance, so to convert it to normal distance, the square root is needed. In the end, we are concatenating both vectors. So you can interpret the result like this
[1 0.5 % first row of variable data belong to cluster 1 and its distance from centrioid of cluster 1 is 0.5
2 0.7 % first row of variable data belong to cluster 2 and its distance from centrioid of cluster 1 is 0.7
1 0.2 % similar intrepretation for all rows
3 1
...
...]