Thank you for that. How can I also choose one that does not match?
Not sure what you mean???
All the combination of two indices which are NOT in the list my program return correspond to values which are farther apart than the tolerance given.
Here is a shorter version of the above with a third function argument.
If the last argument is 1, the function works as the one given above, returning the indices of all pairs which are closer or equal to "tol".
If the third argument is 0, the function returns the indices corresponding to all pair of vector elements which are farther apart than "tol".
Not sure if thats what you had in mind.