Borrar filtros
Borrar filtros

What does the character ~ mean in these code?

5 visualizaciones (últimos 30 días)
Yu Zhang
Yu Zhang el 23 de Mayo de 2012
Hi all, I'm confused by the sentence as following:
[~,ind] = min(dist(:));
Could you tell me what does the character "~" mean in this code?
I appreciate your answer.
  1 comentario
Daniel Shub
Daniel Shub el 23 de Mayo de 2012
Related question: http://www.mathworks.co.uk/matlabcentral/answers/37858-the-sign-is-not-backwards-compatible

Iniciar sesión para comentar.

Respuesta aceptada

the cyclist
the cyclist el 23 de Mayo de 2012
It is a "dummy" output, meaning that even though MATLAB normally generates that output, you know that you do not need it later in your code. In your particular case, you need the second output (the index), but you don't need the first output (the value of the minimum).
  3 comentarios
Walter Roberson
Walter Roberson el 23 de Mayo de 2012
Note: older versions of MATLAB do not support this syntax. If your version of MATLAB reports an invalid operation at that point, then substitute any convenient temporary variable name for the ~ . For example,
[junk, ind] = min(dist(:));
clear junk
Yu Zhang
Yu Zhang el 23 de Mayo de 2012
It works!!!
Thank you VERY much!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by