No products are associated with this question.
The ~ represents an output that is discarded. It is essentially equivalent to:
[dummy,idx]=min(dists); clear dummy
For this example, the code wants to work with the index of the minimum value, not the value itself, so the minimum value that is returned is discarded and only the index is retained.
When you see
>> [a,b,c] = function(...)
then a,b, and c are the output of a function. If you do not want one of the outputs of a function, then you can replace it with the ~ symbol:
>> [a,~,c] = function(...)
and then b will not be output.
Play games and win prizes!Learn more