liliangbiao 发表于 2007-9-3 15:51

Mandelbrot Set集的分形程序

%这是画的Mandelbrot Set集的分形程序(彩色图像)!经过试验和调试是没有错误的!
%给出的图像是w = w.^n+z的组合图像!n=2:1:10;
%下面的程序是n=2的情形,可以n=3…!
Nmax = 50; scale = 0.005;
xmin = -2.4; xmax = 1.2;
ymin = -1.5; ymax = 1.5;
% Generate X and Y coordinates and Z complex values
=meshgrid(xmin:scale:xmax, ymin:scale:ymax);
z = x+1i*y;
% Generate w accumulation matrix and k counting matrix
w = zeros(size(z));
k = zeros(size(z));
% Start off with the first step ...
N = 0;
% While N is less than Nmax and any k's are left as 0
while N<Nmax & ~all(k(: ))
% Square w, add z
w = w.^2+z;
% Increment iteration count
N = N+1;
% Any k locations for which abs(w)>4 at this iteration and no
% previous iteration get assigned the value of N
k(~k & abs(w)>4) = N;
end
% If any k's are equal to 0 (i.e. the corresponding w's never blew up) set
% them to the final iteration number
k(k==0) = Nmax;
% Open a new figure
figure
% Display the matrix as a surface
s=pcolor(x,y,k);
% If you truly want the Mandelbrot curve in B&W, comment the above line and
% uncomment these two
% s = pcolor(x, y, mod(k, 2));
% colormap()
% Turn off the edges of the surface (because the cells are so small, the
% edges would drown out any useful information if we left them black)
set(s,'edgecolor','none')
% Adjust axis limits, ticks, and tick labels
axis()
fontsize=15;
set(gca,'xtick',,'FontSize',fontsize)
set(gca,'ytick',[-ymax:0.5:ymax],'FontSize',fontsize)
xlabel('Re z','FontSize',fontsize)
ylabel('Im z','FontSize',fontsize)

xiaoqiu810818 发表于 2008-1-5 20:18

李大哥,你真是个牛人!

octopussheng 发表于 2008-1-5 21:06

很漂亮,不过个人对这方面还没有研究啊!呵呵,看看了!

sizhiyuan2006 发表于 2017-10-9 14:00

很厉害,学习了
页: [1]
查看完整版本: Mandelbrot Set集的分形程序