% graphics interaction % function square_recursive(level,a,b,len,factor) % % % x(1)=a; x(2)=x(1)+len; x(3)=x(2); % should be 2 not factor. x(4)=x(1); x(5)=x(1); %-------------------- y(1)=b; y(2)=y(1); y(3)=y(2)+len; y(4)=y(3); y(5)=y(1); for i=1:4 line([x(i) x(i+1)],[y(i) y(i+1)]); if(level==1) % text(x(i),y(i),num2str(i)); end end % i % for i=1:level len_small=len/(factor*1.0); square_recursive(level-1,x(1),y(1),len_small,factor); square_recursive(level-1,x(2)-len_small,y(2),len_small,factor); square_recursive(level-1,x(3)-len_small,y(3)-len_small,len_small,factor); square_recursive(level-1,x(4),y(4)-len_small,len_small,factor); end