label 1 and label 3 are in minimum distance 2 but label 2 is not within minimum distance 2 with any of label 1 or 3.
the out put might be like bellow:
0 2 0 0 1 0
0 0 0 1 0 0
0 0 0 1 0 0
0 0 1 1 0 0
0 1 0 0 1 0
1 0 0 0 0 1
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!