Question
Hi, I don't fully understand the linkage function and its outputs. >> x=[1 2 6 8]'; >> y=pdist(x) y = 1 5 7 4 6 2 >> Z=linkage(y) Z = 1 2 1 3 4 2 5 6 4 For Z, what does the first and second column stand for? What is the third column? How was the third column calculated based on the input data x and y?
Expert Answer
John Williams
PhD Expert
Answered Nov 20, 2025
Only just figured it out.
The first and second columns are the new group number after clustering.
4 elements in x each was given a group number from 1 to 4.
The system will then group element 1 and 2 in x together and give a new group number '5'.
The system will then group element 6 and 8 in x together and give a new group number '6'.
The system will at last group '5' and '6' together while group 5 looks like (1,2), and group 6 looks like (6,8).
the third column is the distance between the two group.
first number in column 3 is 1, that is the difference between elements 1 and 2.
second number in column 3 is 2, that is the difference between elements 6 and 8.
third number in column 3 is 4. That is the tricky one. group 5 and group 6 would look like (1,2) and (6,8). Matlab use the shortest euclidean distance by default. Therefore the shortest between two groups will be the 2 from group 5 and the 6 from group 6 with the distance 6-2=4.
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related linkage Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →