Earlier, we said that clustering involves identifying groupings of data. This is possible thanks to the measure of proximity between elements. The term proximity is used to refer to either similarity or dissimilarity. Let's see, then how this can be done in MATLAB.
In MATLAB, we can use the pdist function to calculate the distance between every pair of objects in a dataset. For a dataset made up of k objects, there are k*(k – 1)/2 pairs in the dataset. The result of this computation is commonly known as a distance or dissimilarity matrix; the following figure shows an example: