I have the following routine working:
%New Function
repeat=50;i=0;j=0;r=0;k=50;l=0;npop=10;maxiteration=100000;popmin=100;popmax=10000;popcheck=0;pop1=0;pop2=0;popsize(npop)=0;town(npop,popmax)=0;En(npop,repeat)=0;townsum(npop)=0;for i=1:npop popsize(i)=round(100+rand()*10000); if popsize>popmax popsize=popmax; end townsum(i)=0; for r=1:repeat for j=1:maxiteration randompick1=1+round(rand()*popsize(i)); randompick2=1+round(rand()*popsize(i)); town(i,randompick1)=1; town(i,randompick2)=1; En(i,r)=j; end endend
What I need is to count the iterations it takes to fill each row of the matrix town(i,j) to town(i,popsize(i)). I have tried if, while and keep running afoul of left operator being invalid. En(i,j) is number of iteration it actually takes to fill town(i,j) from town(i,1) to town(i,popsize(i)) with 1's. I need to test sum of town(i,j) until town(i,j)=popsize(i). Any thoughts or help is appreciated.
Best Answer