extract clusters based on the dendrogram
3 views (last 30 days)
Show older comments
In the generated dendrogram graph, the column marks the distance cutoff. Is there a way to get the cluster information for each of these distance cutoffs.
0 Comments
Answers (1)
Mann Baidi
on 29 Apr 2024
I assume that you would like to get th einformation of the cluster from the generated dendrogram plot.
You can find the details of the cluster using the output variable of the 'dendrogram' function. For getting the cluster assign to each data point, you can use the following line of code.
[~,T]=dendrogram(Z,distance_cutoff);
Here 'T' is an array which has the value assigned to each node in the data. For finding the number of nodes, each cluster has you can use the 'histogram' function in MATLAB for plotting the number of nodes in each of the cluster. For reference, you can take help of the foloowing code.
% Sample data
data = 10* rand(100, 2);
% Compute the linkage matrix using 'single' linkage method
Z = linkage(data, 'single');
% Define the distance cutoff
distance_cutoff = 20; % Example cutoff value, adjust as needed
[~,T]=dendrogram(Z,distance_cutoff);
figure;
histogram(T)
Hope I am able to help you in resloving the issue!
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!