i want to sort the value by line not sorting all number . below is my coding and example what i want
%%read data
clc clear %global f d;
%flow
f=[ 0 90 10 23 43 0 0 0 0 0 0 0 90 0 0 0 0 88 0 0 0 0 0 0 10 0 0 0 0 0 26 16 0 0 0 0 23 0 0 0 0 0 0 0 0 0 0 0 43 0 0 0 0 0 0 0 0 0 0 0 0 88 0 0 0 0 0 0 1 0 0 0 0 0 26 0 0 0 0 0 0 0 0 0 0 0 16 0 0 0 0 0 0 96 0 0 0 0 0 0 0 1 0 0 0 0 29 0 0 0 0 0 0 0 0 96 0 0 0 37 0 0 0 0 0 0 0 0 29 0 0 0 0 0 0 0 0 0 0 0 0 37 0 0]; %distance
d=[ 0 36 54 26 59 72 9 34 79 17 46 95 36 0 73 35 90 58 30 78 35 44 79 36 54 73 0 21 10 97 58 66 69 61 54 63 26 35 21 0 93 12 46 40 37 48 68 85 59 90 10 93 0 64 5 29 76 16 5 76 72 58 97 12 64 0 96 55 38 54 0 34 9 30 58 46 5 96 0 83 35 11 56 37 34 78 66 40 29 55 83 0 44 12 15 80 79 35 69 37 76 38 35 44 0 64 39 33 17 44 61 48 16 54 11 12 64 0 70 86 46 79 54 68 5 0 56 15 39 70 0 18 95 36 63 85 76 34 37 80 33 86 18 0]; [r,c]=size(f); max_i=r; max_j=r; max_k=r; max_q=r; MaxIt=10; cp=0.4; % Crossover Percentage
np=2*round(cp*r/2); % Number of Offsprings (Parents)
% % Create Empty Structure
empty_individual.P1=[]; empty_individual.P2=[]; % Create Population Matrix (Array)
pop=repmat(empty_individual,r,1); for no=1:MaxIt ID=randperm(r); %PERMUTATION r NOMBOR ..r = 3, 1 2 3, 1 3 2...
x=zeros(r,r); n=length(ID); x1=ID; for i=1:n for j=1:r x(j,x1(j))=1; B(no).mat=x; % keep memory when 0,1 permuation are make in (i),BINARY for RELATION
end x=zeros(r,r); end z=0;xa=B(no).mat; for i=1:max_i for j=1:max_j for k=1:max_k for q=1:max_q z= z+ f(i,k).*d(j,q).*xa(i,j).*xa(k,q); end end end end no; G(no,:)=[no z]; %STOR ALL VALUE Z 1 HINGGA MaxI IN MATRIX G
F(no,:)=[no z ID]; %STOR ALL VALUE Z and ID, 1 until MaxIt IN MATRIX F
end %end
format compact % Suppresses the display of blank lines.
%
zmin=min(F(:,2)); zmax=max(F(:,2)); Iter_zvalue = F %matrix F have no iter, z and ID
% % Sort Population
% RS = sort(F) % sorted from max to min
i want to sort F by line.. for example
before sorting
1 47764 7 9 4 5 2 1 11 10
2 48878 4 5 10 8 12 11 1 9
3 46388 9 6 4 2 1 10 3 8
4 32014 6 4 12 7 5 1 11 2
5 43468 11 3 8 9 4 10 6 12
6 36962 11 10 4 3 6 5 1 12
7 45400 4 1 10 12 7 11 5 8
8 39032 1 5 9 2 4 10 3 7
9 45742 4 2 5 11 9 3 6 1
10 37436 11 5 3 4 9 10 6 2
After sorting
1 32014 1 1 3 2 1 1 1 1
2 36962 4 2 4 2 2 1 1 2
3 37436 4 3 4 3 4 3 3 2
4 39032 4 4 4 4 4 5 3 7
5 43468 6 5 5 5 5 10 5 8
6 45400 7 5 8 7 6 10 6 8
7 45742 9 5 9 8 7 10 6 9
8 46388 11 6 10 9 9 10 6 10
9 47764 11 9 10 11 9 11 11 12
10 48878 11 10 12 12 12 11 11 12
what i want is that the value in bold just follow the however when i do the sort all the bold number also change.. how can i code so that the bold number did not change, just follow the big number in front.
Best Answer