clustering nearest 5 elements of a data

3 ビュー (過去 30 日間)
sreelekshmi ms
sreelekshmi ms 2020 年 2 月 15 日
コメント済み: sreelekshmi ms 2020 年 2 月 23 日
I have 36 points I need to find the nearest 5 elements of each point and cluster it in a group. Then there is a total of 36 clusters will get. The points are in the 'core' and I need to find the nearest elements from the 'data'. How can I do that? Please help me.
clc;
clear;
data=xlsread('Pimaxl.xlsx');
Si=size(data);
asc=sort(data);
num = numel(data);
diff=unique(asc);
core1=maxk(diff,12);
core2=mink(diff,12);
n = numel(diff(:));
midpoint = ceil(n/2);
core3 = diff(midpoint-5:midpoint+6);
cor=[core1 core2];
core=[cor core3];
  2 件のコメント
Rik
Rik 2020 年 2 月 15 日
core is 12x3, while data is 768x9. What is your definition of point and what is your definition of distance? Is every single element a point and is the distance the absolute difference?
Turlough Hughes
Turlough Hughes 2020 年 2 月 15 日
Have a look at the answer I provided here
You could do the same as that but just replace min with mink. Also as pointed out in the comments a sqrt is not needed.

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

採用された回答

Turlough Hughes
Turlough Hughes 2020 年 2 月 15 日
You could do the following which is to find the 5 minimum absolute differences for each element in core.
[~,idx] = mink(abs(data(:)-core(:).'),5,1);
clusters = data(idx)
Here, the input array to mink is 6912 by 36 where each row corresponds to an element in data and each column corresponds to an element in core and contains every possible absolute difference. The mink function returns an index that you can then sub directly back into data to get your clusters. Clusters is 5 by 36 with each column corresponding to the 36 values in core.
  24 件のコメント
Turlough Hughes
Turlough Hughes 2020 年 2 月 22 日
I can't say unless you show me what your partitioned data looks like. Refer back to my previous comment.
sreelekshmi ms
sreelekshmi ms 2020 年 2 月 23 日
It looks like:

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by