Mandelbrot Set集的分形Matlab实现
6i!eUjm0
.UjK1_nc I,m^0&Dw,I3m.j!z3~0% Author: Thomas Lee
` MR"Y*An7k6ue ^#Rb0% E-mail: lixf1979@126.com % Corresponding: School of Mathematics, Physics and Software Engineering, Lanzhou Jiaotong University, Lanzhou 730070, China 振动资讯B EDwup9a4X"C
振动资讯k bb9K;BK#v4u%hW^t%这是画的Mandelbrot Set集的分形程序(彩色图像)!经过试验和调试是没有错误的!
E-V!ieH.O@6Zb0%给出的图像是w = w.^n+z的组合图像!n=2:1:10;
n#QZ-O ]
z)WUZ1_0%下面的程序是n=2的情形,可以n=3…!
.tyv
fLZ0Nmax = 50; scale = 0.005;振动资讯,?9`
dHB
xmin = -2.4; xmax = 1.2;
3w$]*wOv
mM1|/N0ymin = -1.5; ymax = 1.5;振动资讯4A$xq;J*fcs3L
% Generate X and Y coordinates and Z complex values
8h"u m cr8tF2MK0[x,y]=meshgrid(xmin:scale:xmax, ymin:scale:ymax);
\7]3U0mG2|2@5n-e0z = x+1i*y;
/~dd+j:L_/H9c0% Generate w accumulation matrix and k counting matrix
:R|\d7Ps'wg0w = zeros(size(z));
/b Y+Sz-_7Dk0k = zeros(size(z));振动资讯Cv3FP i Dx9U5C
% Start off with the first step ...
(W0ol3uon0N = 0;振动资讯;mu
{%Cpf;I:O
% While N is less than Nmax and any k's are left as 0
9Ml#L9T:P/L0while N<Nmax & ~all(k(: ))
2g?3M(Tgn]^S4Q1b0% Square w, add z振动资讯w!g$z4^&LMP8T
w = w.^2+z;
(s7ozNCK0% Increment iteration count振动资讯I6Z(^\(zU0O
N = N+1;振动资讯
H rKm3K(|
G'}HmQU
% Any k locations for which abs(w)>4 at this iteration and no振动资讯Lt4@ fk@6tG#|
% previous iteration get assigned the value of N振动资讯 E,pqK:qX"@sQ
k(~k & abs(w)>4) = N;振动资讯 w5_e#V,O@oh
end振动资讯gD*\d-XI
% If any k's are equal to 0 (i.e. the corresponding w's never blew up) set振动资讯YgH!KxjN4c
% them to the final iteration number
HT7R/q&cW?s
q/C0k(k==0) = Nmax;
I.kC[[yu(W$DXc0% Open a new figure振动资讯5l,?0W!P#M)O}
figure振动资讯 g)Z|8bJo
% Display the matrix as a surface振动资讯4OR9~o|?#cA]I
s=pcolor(x,y,k);
|8C*\!bEq4iW0M&E1CC0% If you truly want the Mandelbrot curve in B&W, comment the above line and
l)~[&t0l!L t0% uncomment these two
7MF4w`%z X#{5b0% s = pcolor(x, y, mod(k, 2));
.yzkP7~;A0% colormap([0 0 0;1 1 1])
A*EkV1GCF0% Turn off the edges of the surface (because the cells are so small, the振动资讯,N&xz,Fb
% edges would drown out any useful information if we left them black)振动资讯B~ lI^U
set(s,'edgecolor','none')振动资讯u+p^4q Q.r'beY*Q
% Adjust axis limits, ticks, and tick labels
Y{*K@\7l8l
m0axis([xmin xmax -ymax ymax])
g$G n
~*r9^nTQ0fontsize=15;振动资讯9n `-M7^-ctR-~
set(gca,'xtick',[xmin:0.4:xmax],'FontSize',fontsize)
c,rU$W"Cr0set(gca,'ytick',[-ymax:0.5:ymax],'FontSize',fontsize)振动资讯)^P4T8f!}
xlabel('Re z','FontSize',fontsize)
@S:\'^ Z!o+y0ylabel('Im z','FontSize',fontsize)振动资讯'un_m-gwU
9Aa"M'O,vT0fractles.gif
TAG:
-
xiaoqiu810818发布于2008-01-05 20:18:11
-
李大哥,你真是个牛人!
-
octopussheng 发布于2008-01-05 21:06:21
-
很漂亮,不过个人对这方面还没有研究啊!呵呵,看看了!
