function Fractree(ss,ms,sf,A); % 递归法生成分形树 % ss is Starting size % ms is Minimum Size % sf is Shrink Factor % A is Angle A=A/180*pi; L=ss; jd=pi/2; z=0; cla; hold on; [z,jd,L]=recursionN(z,jd,L,ms,sf,A); hold off set(gca,'color','k'); xlim([-128,128]); ylim([-128,128]) function [z,jd,L]=recursionN(z,jd,L,ms,sf,A); % 进行递归计算 z1=z+L*exp(i*(jd-A)); z2=z+L*exp(i*(jd+A)); plot([z1,z,z2],'y'); if L>ms; jd=jd-A; L=L/sf; [z1,jd,L]=recursionN(z1,jd,L,ms,sf,A); jd=jd+2*A; [z2,jd,L]=recursionN(z2,jd,L,ms,sf,A); jd=jd-A; L=L*sf; end
matlab创造算法,MATLAB 分形树生成算法(一)
最新推荐文章于 2021-04-02 08:45:22 发布