[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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With