clc;clear all;close all; Distance = [0,2,4,6,6,8; 2,0,4,6,6,8; 4,4,0,6,6,8; 6,6,6,0,4,8; 6,6,6,4,0,8; 8,8,8,8,8,0]; S = ['A','B','C','D','E','F']; L = length(Distance(:,1)); r= []; SResult = []; STemp = []; %% NJ Algorithmwhile L > 2 %calculate r(i)=…