Effacer les filtres
Effacer les filtres

What does the Tilde (~) mean here in this code?

36 vues (au cours des 30 derniers jours)
Daniel Tanner
Daniel Tanner le 18 Déc 2019
Modifié(e) : Adam Danz le 18 Déc 2019
I have read the doc's for using the tilde (~) key, however I do not understand what is going on properly. I have a vector A of dimensios: 1359 by 1 where the values range from 0 to a max of 42.7. However, when I type this line of code, i get an output of 5001 and I am unsure why after even looking at the help doc.
[~,G] = max(A,1));
I am confused here because the max value of A is 42.7 so I am not sure why it is outputting G as 5001?
I'm sure the explanantion is simple once I get my head round it! Any help is greatly appreciated, thank you.

Réponse acceptée

Adam Danz
Adam Danz le 18 Déc 2019
Modifié(e) : Adam Danz le 18 Déc 2019
[M,I] = max(___) has two outputs. The first is the maximum value of the input and the second is the index of the maximum value.
[~,I] = max(___)) : The tilde merely suppresses the first output. This is done when the first n-outputs are not needed rather than assigning superfluous variables to them that are never used in the code.
For more info:

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by