1function centroids = kMeansInitCentroids(X, K) 2%KMEANSINITCENTROIDS This function initializes K centroids that are to be 3%used in K-Means on the dataset X 4% centroids = KMEANSINITCENTROIDS(X, K) returns K initial centroids to be 5% used with the K-Means on the dataset X 6% 7 8% You should return this values correctly 9centroids = zeros(K, size(X, 2)); 10 11% ====================== YOUR CODE HERE ====================== 12% Instructions: You should set centroids to randomly chosen examples from 13% the dataset X 14% 15randidx = randperm(size(X, 1)); 16centroids = X(randidx(1:K), :); 17% ============================================================= 18 19end 20 21 22