I have a set of data points, which are complex numbers which have, let’s say, 8 rows and 6 columns. If you look at the program, you can see that data sets are arranged very randomly. 1st, 2nd, 3rd columns are okay, but 4th column, is bit anomalous. What I mean to say is that after element at B(5, 4) (i.e. 25.9868674011374) it is coming 2.74257567017122 [B(6, 4)] instead of 26.8410063269595 which has gone to B(6, 6). I want that column arranged in ascending order (every sorting should be done for real part). Also, in the 5th column, even though the real parts ae arranged in ascending order, the imaginary part are kind of swapped. For example, after B(2,5) it should be B(3,6) not B(3,5). I have tried ‘sort’ command, but it not working as I want.
For the people who is wondering wht is the problem with sort, just try to run this command:
A = [1+2i 3+i i 0 -i];
Dimg = sort(imag(A));
What I want is -i, 0, i ,3+I,1+2i, what sort gives is something else.
Also, there may be instances where 4th, 5th and 6th column may behave ‘normally’, but 1st, 2nd, 3rd columns behaving erratically. So even if 4th, 5th and 6th columns are behaving ‘normally’ I want it to be sorted down in ascending order. Any way through this? By the by, I am using Matlab- 2015b. The code is:
clear all; clc;
B=[-2.14981736484179 + 0.00000000000000i,-1.38134547606946 + 0.00000000000000i,1.38451324569297 + 0.00000000000000i,22.5759136576435 + 0.00000000000000i,2.28536796878740 + 0.333911501246080i,2.28536796878740 - 0.333911501246080i;-2.22047322414157 + 0.00000000000000i,-1.43596350944258 + 0.00000000000000i,1.43889226552228 + 0.00000000000000i,23.4278498788255 + 0.00000000000000i,2.39484729461819 + 0.303429715954385i,2.39484729461819 - 0.303429715954385i;-2.29148887606605 + 0.00000000000000i,-1.49057388951113 + 0.00000000000000i,1.49328382360683 + 0.00000000000000i,24.2803021611395 + 0.00000000000000i,2.50423839041542 - 0.265225265037282i,2.50423839041542 + 0.265225265037282i;-2.36284412024645 + 0.00000000000000i,-1.54517861014711 + 0.00000000000000i,1.54768832224205 + 0.00000000000000i,25.1333019698605 + 0.00000000000000i,2.61351621914550 + 0.215386193278572i,2.61351621914550 - 0.215386193278572i;-2.43451884781340 + 0.00000000000000i,-1.59977935450756 + 0.00000000000000i,1.60210590260749 + 0.00000000000000i,25.9868674011374 + 0.00000000000000i,2.72266244928806 - 0.142395604889199i,2.72266244928806 + 0.142395604889199i;-2.50649346218904 + 0.00000000000000i,-1.65437753673930 + 0.00000000000000i,1.65653651325774 + 0.00000000000000i,2.74257567017122 + 0.00000000000000i,2.92075248853987 + 0.00000000000000i,26.8410063269595 + 0.00000000000000i;-2.57874914363635 + 0.00000000000000i,-1.70897433922564 + 0.00000000000000i,1.71097996266870 + 0.00000000000000i,2.74509085049068 + 0.00000000000000i,3.13593380433481 + 0.00000000000000i,27.6957188653678 + 0.00000000000000i;-2.65126800477853 + 0.00000000000000i,-1.76357074549849 + 0.00000000000000i,1.76543595943333 + 0.00000000000000i,2.78382099280761 + 0.00000000000000i,3.31458248082037 + 0.00000000000000i,28.5509993172157 + 0.00000000000000i];
Thanks in advance...