error in the code
erroe in string(j,n)=string(k,n);
for k=1:Npop
for j=1:dim
busLocation(j,k)=busd(busLocation(j,k),1);
end
sdf= unique(busLocation(:,k));
while length(sdf)<dim
sdf=randi([2 length(busd(:,1))],dim,1);
for j=1:dim
sdf(j)=busd(sdf(j),1);
end
busLocation(:,k)=sdf;
sdf= unique(busLocation(:,k));
end
end
ndif = [0.28; 0.35; 0.39; 0.35; 0.27; 0.34; 0.40; 0.34; 0.25; 0.32];
for k = 1:Npop
mdif(k)= ndif(k);
end
nsw=length(string);
mpop = round(Npop/4);
for j = 1:mpop
minman = min(mdif(:));
for k = 1:Npop
if mdif(k)== minman
for n=1:nsw
string(j,n)=string(k,n);
end
mdif(k)= 1010;
break;
end
end
end
for j = 1:(Npop-mpop)
for bits=1:nsw
string(mpop +j,bits) = string(j,bits);
end
end ; enderroe in string(j,n)=string(k,n);
for k=1:Npop
for j=1:dim
busLocation(j,k)=busd(busLocation(j,k),1);
end
sdf= unique(busLocation(:,k));
while length(sdf)<dim
sdf=randi([2 length(busd(:,1))],dim,1);
for j=1:dim
sdf(j)=busd(sdf(j),1);
end
busLocation(:,k)=sdf;
sdf= unique(busLocation(:,k));
end
end
ndif = [0.28; 0.35; 0.39; 0.35; 0.27; 0.34; 0.40; 0.34; 0.25; 0.32];
for k = 1:Npop
mdif(k)= ndif(k);
end
nsw=length(string);
mpop = round(Npop/4);
for j = 1:mpop
minman = min(mdif(:));
for k = 1:Npop
if mdif(k)== minman
for n=1:nsw
string(j,n)=string(k,n);
end
mdif(k)= 1010;
break;
end
end
end
for j = 1:(Npop-mpop)
for bits=1:nsw
string(mpop +j,bits) = string(j,bits);
end
end ; end erroe in string(j,n)=string(k,n);
for k=1:Npop
for j=1:dim
busLocation(j,k)=busd(busLocation(j,k),1);
end
sdf= unique(busLocation(:,k));
while length(sdf)<dim
sdf=randi([2 length(busd(:,1))],dim,1);
for j=1:dim
sdf(j)=busd(sdf(j),1);
end
busLocation(:,k)=sdf;
sdf= unique(busLocation(:,k));
end
end
ndif = [0.28; 0.35; 0.39; 0.35; 0.27; 0.34; 0.40; 0.34; 0.25; 0.32];
for k = 1:Npop
mdif(k)= ndif(k);
end
nsw=length(string);
mpop = round(Npop/4);
for j = 1:mpop
minman = min(mdif(:));
for k = 1:Npop
if mdif(k)== minman
for n=1:nsw
string(j,n)=string(k,n);
end
mdif(k)= 1010;
break;
end
end
end
for j = 1:(Npop-mpop)
for bits=1:nsw
string(mpop +j,bits) = string(j,bits);
end
end ; end for study MATLAB Answers — New Questions