K-means implementation for matrix A(n x m) that returns a vector of length n with values from 1 to k, depending on which cluster the vector ended in

2 views (last 30 days)
Hi,
Sorry for bad english
Here is my task
I need to implement the function mykmeans (A, k), where the input wil be a matrix A with dimensions n x m, where n will be the number of vectors and m is the length of the flag vector. k will be the parameter of the k-means algorithm. The function returns a vector of length n in which the integer values will be 1 to k, depending on which cluster the vector ended in. I need to initialize the centroids so that they are in the areas where the input vectors are located.
Can someone hel me with this task?
Thank you
Best regards, Arsen

Answers (1)

KALYAN ACHARJYA
KALYAN ACHARJYA on 24 Jan 2021
Edited: KALYAN ACHARJYA on 24 Jan 2021
  2 Comments
Arsen Driashkaba
Arsen Driashkaba on 24 Jan 2021
Hi,
Thank you for your reply,
I need to implement my own function that returns a vector of lenght n with values from 1 to k.
if you have any ideas could you help me with this?
Best regards, Arsen
Image Analyst
Image Analyst on 24 Jan 2021
Are you saying that you're not allowed to use the built-in kmeans() function(s), or any code from anyone else either? And that you need to write your own kmeans function without any help from us or Mathworks? I believe you can probably find the algorithm in Wikipedia or elsewhere on the web.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!