文件名称:fractal-use
-
所属分类:
- 标签属性:
- 上传时间:2013-03-02
-
文件大小:42.8kb
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
分形的练习一
①Koch曲线
用复数的方法来迭代Koch曲线
clear i 防止i被重新赋值
A=[0 1] 初始A是连接(0,0)与(1,0)的线段
t=exp(i*pi/3)
n=2 n是迭代次数
for j=0:n
A=A/3 a=ones(1,2*4^j)
A=[A (t*A+a/3) (A/t+(1/2+sqrt(3)/6*i)*a) A+2/3*a]
end
plot(real(A),imag(A))
axis([0 1 -0.1 0.8])
②Sierpinski三角形
A=[0 1 0.5 0 0 1] 初始化A
n=3 迭代次数
for i=1:n
A=A/2 b=zeros(1,3^i) c=ones(1,3^i)/2
A=[A A+[c b] A+[c/2 c]]
end
for i=1:3^n
patch(A(1,3*i-2:3*i),A(2,3*i-2:3*i), b ) patch填充函数
end
-Fractal
Exercise One
The ① Koch curve
Plural iteration Koch curve
clear i to prevent i is reassigned
A = [0 1] initial A is a connection (0,0) and (1,0) of the segments
t = exp (i* pi/3)
n = 2 n is the number of iterations
for j = 0: n
A = A/3 a = ones (1,2* 4 ^ j)
A = [A (t* A+ a/3) (A/t+ (1/2+ sqrt (3)/6* i)* a) A+2/3* a]
end
plot (real (A), imag (A))
axis ([0 1-0.1 0.8])
② Sierpinski triangle
A = [0 1 0.5 0 0 1] initialized A
n = 3 the number of iterations.
for i = 1: n
A = A/2 b = zeros (1,3 ^ i) c = ones (1,3 ^ i)/2
A = [A A+ [c b] A+ [c/2 c]]
end
for i = 1:3 ^ n
patch (A (1,3* i-2: 3* i), A (2,3* i-2: 3* i), b ) patch filled function
end
①Koch曲线
用复数的方法来迭代Koch曲线
clear i 防止i被重新赋值
A=[0 1] 初始A是连接(0,0)与(1,0)的线段
t=exp(i*pi/3)
n=2 n是迭代次数
for j=0:n
A=A/3 a=ones(1,2*4^j)
A=[A (t*A+a/3) (A/t+(1/2+sqrt(3)/6*i)*a) A+2/3*a]
end
plot(real(A),imag(A))
axis([0 1 -0.1 0.8])
②Sierpinski三角形
A=[0 1 0.5 0 0 1] 初始化A
n=3 迭代次数
for i=1:n
A=A/2 b=zeros(1,3^i) c=ones(1,3^i)/2
A=[A A+[c b] A+[c/2 c]]
end
for i=1:3^n
patch(A(1,3*i-2:3*i),A(2,3*i-2:3*i), b ) patch填充函数
end
-Fractal
Exercise One
The ① Koch curve
Plural iteration Koch curve
clear i to prevent i is reassigned
A = [0 1] initial A is a connection (0,0) and (1,0) of the segments
t = exp (i* pi/3)
n = 2 n is the number of iterations
for j = 0: n
A = A/3 a = ones (1,2* 4 ^ j)
A = [A (t* A+ a/3) (A/t+ (1/2+ sqrt (3)/6* i)* a) A+2/3* a]
end
plot (real (A), imag (A))
axis ([0 1-0.1 0.8])
② Sierpinski triangle
A = [0 1 0.5 0 0 1] initialized A
n = 3 the number of iterations.
for i = 1: n
A = A/2 b = zeros (1,3 ^ i) c = ones (1,3 ^ i)/2
A = [A A+ [c b] A+ [c/2 c]]
end
for i = 1:3 ^ n
patch (A (1,3* i-2: 3* i), A (2,3* i-2: 3* i), b ) patch filled function
end
(系统自动生成,下载前可以参看下载内容)
下载文件列表
分形.doc
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.