声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2891|回复: 3

[分形与混沌] Mandelbrot Set集的分形程序

[复制链接]
发表于 2007-9-3 15:51 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
%这是画的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
[x,y]=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([0 0 0;1 1 1])
% 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([xmin xmax -ymax ymax])
fontsize=15;
set(gca,'xtick',[xmin:0.4:xmax],'FontSize',fontsize)
set(gca,'ytick',[-ymax:0.5:ymax],'FontSize',fontsize)
xlabel('Re z','FontSize',fontsize)
ylabel('Im z','FontSize',fontsize)
fractles.gif

本帖被以下淘专辑推荐:

回复
分享到:

使用道具 举报

发表于 2008-1-5 20:18 | 显示全部楼层
李大哥,你真是个牛人!
发表于 2008-1-5 21:06 | 显示全部楼层
很漂亮,不过个人对这方面还没有研究啊!呵呵,看看了!
发表于 2017-10-9 14:00 | 显示全部楼层
很厉害,学习了
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-12-23 07:00 , Processed in 0.061394 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表