- [I,I] = sort(X)
- [trash,I] = sort(X)
Ignore output arguments (R2006a)
3 views (last 30 days)
Show older comments
Some versions of MATLAB allow to ignore selected output arguments by using '~'. How can I do that in R2006a (v7.2)?
For example: [Y,I]=sort(X) --> [~,I]=sort(X); I just want the second output
Thanks in advance
0 Comments
Accepted Answer
Oleg Komarov
on 3 Apr 2012
You cannot.
What you can do is:
In the first case, you'll keep only one variable in the workspace, but it's not very elegant (in my opinion). In the second case, it's immediate that you need only the second output.
2 Comments
Jan
on 3 Apr 2012
The [I,I] method forces me to think twice when I read the code, while the [trash, I] is trivial. An option is to add "clear('trash')" to release the occupied memory.
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices 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!