help with kmeans clustering
이전 댓글 표시
hello I'm working on k-means clustering algorithms I'm using the default function of matlab
when i read the documentation i found that the distance hamming used only with binary dataset
so i tried this :
B=randi([2:3],[150,7])>2;
>> idx=kmeans(B,4,'Distance','hamming');
it's so clear that B is binary but when i click on run button i obtain this error
Undefined function 'kmeans2' for input arguments of type 'struct'.
Error in kmeans (line 322)
[varargout{1:nargout}] = kmeans2(X,k, distance, emptyact,reps,start,...
any ideas about where the problem is .?
댓글 수: 11
Star Strider
2019년 6월 6일
Actually, ‘B’ is logical.
Your code runs for me (in R2019a) without error, producing a (150x1) double array in ‘idx’.
What is the result when you run:
whos('B')
When I run it, I get:
Name Size Bytes Class Attributes
B 150x7 1050 logical
If you get a different result, that could help define the problem.
Abdelmalek Benaimeur
2019년 6월 6일
Star Strider
2019년 6월 6일
O.K. My hypothesis was that you had already defined ‘B’ as a structure, and that was causing the problem.
I copied your code, pasted it to a script, and ran it without problems. I’m now out of ideas.
KSSV
2019년 6월 7일
Which version you are using? It is running fine in 2017b. Can you tell what
which kmeans
outputs?
Abdelmalek Benaimeur
2019년 6월 7일
편집: Abdelmalek Benaimeur
2019년 6월 7일
Walter Roberson
2019년 6월 7일
Please show the output of
which -all kmeans2
Abdelmalek Benaimeur
2019년 6월 7일
Walter Roberson
2019년 6월 7일
Wait... the run button? What you posted for was run at the command window, not with the run button. If you are using the run button, then your B might be something different.
Put in a breakpoint at line 322 of kmeans (the call to kmeans2) and examine the variables to figure out which of them is a structure. On my system, RNGscheme shows up as a structure but none of the other variables.
Abdelmalek Benaimeur
2019년 6월 7일
Walter Roberson
2019년 6월 7일
dbstop if error, run, and examine the parameters being passed to the call.
Abdelmalek Benaimeur
2019년 6월 11일
편집: Abdelmalek Benaimeur
2019년 6월 11일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 k-Means and k-Medoids Clustering에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!