Did you ever see '~' symbol at return value of function?
Afficher commentaires plus anciens
There is a function as follow
: function [y z] = func_add_minus(a, b)
And 'func_add_minus' is called as follow
[~, zz] = func_add_minus(1,2)
I have naver seen this receive format. I don't know how can I understand '~' symbol.
Did you ever see '~' symbol at return value of function?
Réponses (3)
Wayne King
le 13 Sep 2012
~ means to suppress an output argument.
so
[~,zz] = func_add_minus(1,2);
means that you only want to return the 2nd output argument, zz, and not y in this case.
Jan
le 13 Sep 2012
The ~ works since R2009b. An equivalent for former versions:
[dummy, zz] = func_add_minus(1,2);
clear('dummy'); % Useful if dummy occupies a lot of memory
2 commentaires
Andrei Bobrov
le 13 Sep 2012
or
[zz, zz] = func_add_minus(1,2);
Jan
le 15 Sep 2012
As usual I explain, that I still have to think twice, if the final value of z is the first or the last output.
Kim Eun Hyouek
le 15 Sep 2012
0 votes
1 commentaire
Oleg Komarov
le 15 Sep 2012
Please accept an answer.
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!