The if Commadn needs a scalar condition. Because NewDist(:) < 1 is a vector, Matlab inserts an all() automatically. So your code is equivalent to:
This is not, what you want, most likely.
is a waste of time only. Just omit it.
Better with logical indexing:
tooSmall = (NewDist < 1);
In the line
the square brackets are not useful by a (tiny) wate of time only. [ ] is the Matlab operator for a concatenation. 1:100 is a vector already and you concatenate it with nothing.
This is a problem also. The for loop processes the values of its argument in columns. So this loop run 1 time only and sets Distanc to DS(:). If this is wanted, use the more direct an clear:
without a pseudo for loop,