So I have a vector that contains complex values. I want to sort them in order of ascending imaginary order. Is there a way to do this?
Accorsing to the sort documentation, sort
will sort via magnitude.
Thanks
Please try something like this:
a = [1 + 1i; 1 - 1i; 1 - 2*1i];
[sorted, idx] = sort(imag(a));
a = a(idx);
a =
1.0000 - 2.0000i
1.0000 - 1.0000i
1.0000 + 1.0000i
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.