hi,
I have a data set of 1000x2 dimensions, I need to apply k-mean clustering on it with k=4, without using the built in k means function in matlab, and my starting points are: (0,0) , (1,1) , (-1,-1) , (-1,1); however I got stuck trying to index (0,0) since matlab index is positive integer above 1, any ideas how can I solve this problem?
thank you in advance any help is appreciated
above is my data set

5 件のコメント

Rik
Rik 2022 年 12 月 30 日
Why would the indexing with positive integers be related to this task?
I suspect it would help if you posted your code.
John D'Errico
John D'Errico 2022 年 12 月 30 日
編集済み: John D'Errico 2022 年 12 月 30 日
So where is the problem? Just learn to use an index origin of 1. (That is, the first element in a vector is indexed at 1, NOT 0.) Essentially, that means you need to learn to use MATLAB, since EVERYTHING you do in MATLAB assumes an index origin of 1, NOT 0, as you seem to want. If you want a better answer, then you need to show your code, since all we can do when you show no code, is that you should write better code.
In this case, the problem is clearly you think all languages use an index origin of 0.
Bayan Bishara
Bayan Bishara 2023 年 1 月 3 日
I do know that indexing in matlab starts from 1 not 0, but my HW requires me to calculate with the multiple starting points mentioned including (0,0),
I probably wasn't clear, but I'm supposed to build my own algorithm and not use the built in function of k mean in matlab
Image Analyst
Image Analyst 2023 年 1 月 3 日
Array indexing starts at 1, however the values IN the array can be anything. So if the data are (x,y) coordinates, you can certainly have 0 and negative values in there. For example
data = [0, 0;
-1, -3;
-4, 6;
3, 8]
data has 4 rows and 2 columns with numbering starting at 1 and going to 4 and 2 respectively. However the (x,y) coordinates stored in data have 0 and negative coordinate values.
Bayan Bishara
Bayan Bishara 2023 年 1 月 4 日
編集済み: Bayan Bishara 2023 年 1 月 4 日
s= [0 0 ; 1 1 ; -1 -1 ; -1 1 ]; %starting points
I tried it and it instead of what I was trying initially:
for i=size(s)
i=(0,0)
...
it worked!! thank you so much!

サインインしてコメントする。

 採用された回答

Image Analyst
Image Analyst 2022 年 12 月 30 日

0 投票

Since you can't use MATLAB's function, I guess you can't use any other implementations that you find anywhere on the internet either. So you're stuck with making your own kmeans from scratch. Good luck. Maybe you can start here:

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by