averagediffusiondistanceimplementedinmatlab