Problem with Cluster command

3 次查看(过去 30 天)
When I ran the following three commands from the Statistics and Machine Learning Toolbox in the shown order, in my command window
Y = pdist(X)
Z - linkage(Y)
T = cluster(Z,'cutoff',1.2)
where X is 3042x53 matrix of type double, I get the following error (just after I execute statement 3) "Index in position 1 is invalid. Array indices must be positive integers or logical values." I then repeated these commands with a smaller X input (4x8). Same result. I believe that "cluster" wants integers for the first two columns of the Z input, (Z was produced by linkage) but the last column of Z is a distance measure and is real - so all columns of Z must be real. What am I doing wrong or misunderstanding?

采纳的回答

Walter Johnson
Walter Johnson 2020-1-26
Well thanks. It's something I will be looking out for now

更多回答(1 个)

Walter Roberson
Walter Roberson 2020-1-24
Z = linkage(squareform(Y)) ;
  6 个评论
Walter Johnson
Walter Johnson 2020-1-26
Ha, Bingo! Thanks a lot. Did you guess this because it happens fairly often? I feel pretty dumb.
Walter Roberson
Walter Roberson 2020-1-26
It does happen a fair bit, most commonly with a variable named sum .

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by