Did you ever see '~' symbol at return value of function?
Show older comments
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?
Answers (3)
Wayne King
on 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
on 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 Comments
Andrei Bobrov
on 13 Sep 2012
or
[zz, zz] = func_add_minus(1,2);
Jan
on 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
on 15 Sep 2012
0 votes
1 Comment
Oleg Komarov
on 15 Sep 2012
Please accept an answer.
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!