You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: kmeans.m
    path of file: ./repos/MataveID/matave/+mi
    
    the code of the file until where you have to start completion: % K-means clustering
% Input: X(data), k(amount of clusters)
% Output: idx(row index of class ID), C(coordinates 
    
function [idx, C, success] = kmeans(X, k)
  % Get size of X
  [m, n] = size(X);

  % Find a random initial start
  C = X(randperm(m, k), :);

  % Iterate the solution
  max_iter = 100;
  old_value = 0;
  for i = 1:max_iter
      % Compute euclidean distance
      D = euclidean_distance(X, C);

      % Create points to nearest cluster
      [~, idx] = min(D, [], 2);

      % Update the center of the cluster coordinates
      for j = 1:k
          C(j,:) = mean(X(idx == j, :), 1);
      end