Mandelbrot Set集的分形Matlab实现

上一篇 / 下一篇  2007-09-03 15:53:33

查看( 265 ) / 评论( 2 )
振动资讯0yZ%oyD8G

振动资讯P'R${WO&[s.B+]IH

"W U+CQxh p1A\0% Author: Thomas Lee振动资讯&\k,L1L{(z

% E-mail: lixf1979@126.com % Corresponding: School of Mathematics, Physics and Software Engineering, Lanzhou Jiaotong University, Lanzhou 730070, China 振动资讯.G X,zk'h4X

}Nl?rY!c0%这是画的Mandelbrot Set集的分形程序(彩色图像)!经过试验和调试是没有错误的!振动资讯9f @b]@7Z
%给出的图像是w = w.^n+z的组合图像!n=2:1:10;
Mwo8u f*J@W$f0%下面的程序是n=2的情形,可以n=3…!
]8rgK5w(z0Nmax = 50; scale = 0.005;
Fv/s L I? {w Ct+pH0xmin = -2.4; xmax = 1.2;振动资讯W#S8n4?8~t"?
ymin = -1.5; ymax = 1.5;
.j)\ W)[O`N.r0% Generate X and Y coordinates and Z complex values振动资讯 c r&^3^u8R0t
[x,y]=meshgrid(xmin:scale:xmax, ymin:scale:ymax);振动资讯ggm v{pD._[
z = x+1i*y;
^)d/Xg"R R0% Generate w accumulation matrix and k counting matrix振动资讯U8S ZLI3f9~Uv
w = zeros(size(z));振动资讯;S{'z-NVi;S8c
k = zeros(size(z));振动资讯0nr&A Pjt
% Start off with the first step ...
$` ?A8Z.LY/U c3j r0N = 0;
@Xf,P#@`K8Y0% While N is less than Nmax and any k's are left as 0 振动资讯!^Rt,fdIXP[JZ
while N<Nmax & ~all(k(: ))
P `e'un |0% Square w, add z
`l(l{~J#i"A7w0w = w.^2+z;振动资讯Kr+OK0e5b*^ ]u
% Increment iteration count
)G u%Y2Wn0T(O;c#ny0N = N+1;
;D [,xO:qi;t0% Any k locations for which abs(w)>4 at this iteration and no振动资讯'xi6jF!jp
% previous iteration get assigned the value of N振动资讯4SB$u9o4x ["h'`&C
k(~k & abs(w)>4) = N;
o'EAOO@~"U x0end振动资讯7zR(R OKb3f R7J
% If any k's are equal to 0 (i.e. the corresponding w's never blew up) set
P o,j$rZG0% them to the final iteration number
^ix^?Xft0k(k==0) = Nmax;
u Ws7N6H0% Open a new figure
1o6d1l[(bi7t*W(k[nQ.w0figure振动资讯&y,Xg w^Tw s
% Display the matrix as a surface振动资讯E\s1_j"u
s=pcolor(x,y,k);
#I&MOD/Y0% If you truly want the Mandelbrot curve in B&W, comment the above line and
;?nyNG0% uncomment these two
_n0`f$g0% s = pcolor(x, y, mod(k, 2));
c!Vx?X!s3M0% colormap([0 0 0;1 1 1])
J3U6c\ _H0% Turn off the edges of the surface (because the cells are so small, the振动资讯 A3I+U[S.Nz"v
% edges would drown out any useful information if we left them black)
q3Ue Zl0set(s,'edgecolor','none')振动资讯R,V Q*Ge%ZQH
% Adjust axis limits, ticks, and tick labels振动资讯hfe]7TN
axis([xmin xmax -ymax ymax])
y4K$vy'L0fontsize=15;振动资讯1PK.L,Z3zI,t
set(gca,'xtick',[xmin:0.4:xmax],'FontSize',fontsize)振动资讯 ZQ7T`;Y-p v3zP
set(gca,'ytick',[-ymax:0.5:ymax],'FontSize',fontsize)
N6Se7R2E,x"M h0xlabel('Re z','FontSize',fontsize)振动资讯tc6oi"^fO;\3Xqg]
ylabel('Im z','FontSize',fontsize)
Vs#Et-M ]y9cK9w0振动资讯 K ZO&oI3S(L
fractles.gif

$DNuu&O0

TAG:

xiaoqiu810818发布于2008-01-05 20:18:11
李大哥,你真是个牛人!
octopussheng的个人空间 octopussheng 发布于2008-01-05 21:06:21
很漂亮,不过个人对这方面还没有研究啊!呵呵,看看了!
我来说两句

(可选)

关于作者