First, I have just realized that my first post was wrong (cause the final matrix is not the same). This is better :
1)timer();A=[];for i=1:100000,A=[A;i];,end;timer() ans = 16.489306 2)timer();B=[];for j=1:10,A=[];for i=1:10000,A=[A;i];,end;B=[B;A+(j-1)*10000];,end;timer() ans = 1.0452067 3)timer();B=[];for j=1:100,A=[];for i=1:1000,A=[A;i];,end;B=[B;A+(j-1)*1000];,end;timer() ans = 0.4368028 So same conclusion! In this case, splitting the for loop does not work well.... -->timer();A=zeros(1,100000);for i=1:100000,A(i)=i;end;timer() ans = 0.4368028 -->timer();B=[];for j=1:100,A=zeros(1,1000);for i=1:1000,A(i)=i;end;,B=[B A+(j-1)*1000];,end;timer() ans = 0.4212027 However this loop is an example to illustrate. In my case here are the kind of loop I use 1)A=mopen('myfile.txt'); X=[];Y=[];Z=[]; winH=waitbar('Coffee break'); for i=1:1000000, B=mgetl(-1,A); [n,x,y,z]=msscanf(1,B,'%*s %*d:%*d:%*f,%d,%d,%d'); X=[X;x];Y=[Y;y];Z=[Z;z]; waitbar(j/1000000,winH); ,end; =>30minutes (I guess cause it's so long that I stopped the loop) 2)A=mopen('myfile.txt'); X=[];Y=[];Z=[]; winH=waitbar('Coffee break'); for j=1:100, X2=[];Y2=[];Z2=[]; for i=1:10000, B=mgetl(-1,A); [n,x,y,z]=msscanf(1,B,'%*s %*d:%*d:%*f,%d,%d,%d'); X2=[X2;x];Y2=[Y2;y]; ,end; Z2=[Z2;z];X=[X;X2];Y=[Y;Y2];Z=[Z;Z2]; waitbar(j/100,winH); ,end; =>1 minutes -- View this message in context: http://mailinglists.scilab.org/For-loop-maximum-size-tp4025172p4025174.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. _______________________________________________ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users