|
From: | Tom Holroyd |
Subject: | Re: sorting complex numbers |
Date: | Wed, 25 Oct 2006 21:27:53 -0400 (EDT) |
Is there a way to sort complex numbers by either the real or imaginary part and be able to retain the whole complex number?
Yes. octave:1> a = [1, 2+i, -1-i, -2+3i]; octave:2> [s, i] = sort(real(a)); octave:3> a(i) ans = -2 + 3i -1 - 1i 1 + 0i 2 + 1i
[Prev in Thread] | Current Thread | [Next in Thread] |