How to ignore output variables in matlab?
matlab
Solution
You have to add a comma and separate the output arguments to get ~ to work.
The following works
[dummy index] = sort(A);
[dummy, index] = sort(A);
[~, index] = sort(A);
but
[~ index] = sort(A);
fails.
Problem
``` [dummy index] = sort(A); ``` I want to ignore the first output of sort function and just keep the indices. When I use the above I get a warning in the matlab editor that: The value assigned to dummy is appears to be unused. and it suggest to use ~ instead. When I use ~. ``` [~ index] = sort(A); ``` I got the following error: use ~ to ignore a value is not permitted in this context. Anyone has a solution for this?