当前位置:首页 > Matlab分形几何制图程序
Matlab分形几何制图程序
clear all
new=[0.5+(sqrt(3)/2*i),-0.5+(sqrt(3)/2*i),0,0.5+(sqrt(3)/2*i)]; subplot(2,3,1) plot(new) axis equal for k=1:5; old=new; n=length(old)-1; for j=0:n-1;
diff=(old(j+2)-old(j+1))/3; new(j*4+1)=old(j+1);
new(j*4+2)=old(j+1)+diff;
new(j*4+3)=new(4*j+2)+diff*((1-sqrt(3)*i)/2); new(j*4+4)=old(j+1)+2*diff; end
new(4*n+1)=old(n+1); subplot(2,3,k+1) plot(new); axis equal; end
这是老师给的,与大家分享一下
下面的是根据老师的自己写的
clear all new=[0,i]; subplot(2,3,1) plot(new); for k=1:5; old=new;
n=length(old)-1; for j=0:n-1;
diff=(old(j+2)-old(j+1))/3; new(j*7+1)=old(j+1);
new(j*7+2)=old(j+1)+diff; if abs(new(j+1)) new(j*7+3)=new(j*7+2)+diff*((sqrt(3)+i)/2); new(j*7+4)=new(j*7+2); new(j*7+5)=new(j*7+4)+diff; new(j*7+6)=new(j*7+5)+diff*((sqrt(3)-i)/2); new(j*7+7)=new(j*7+5); else new(j*7+1)=old(j+1); new(j*7+2)=old(j+1); new(j*7+3)=new(j*7+2); new(j*7+4)=new(j*7+2); new(j*7+5)=new(j*7+4); new(j*7+6)=new(j*7+5); new(j*7+7)=new(j*7+5); end end new(7*n+1)=old(n+1); subplot(2,3,k+1) plot(new); axis equal; end
共分享92篇相关文档