function fern%FERN MATLAB implementation of the Fractal Fern% Michael Barnsley, Fractals Everywhere, Academic Press, 1993.% This version runs forever, or until stop is toggled.% See also FINITEFERN.shgclf resetset(gcf,'color','white','menubar','none', ... 'numbertitle','off','name','Fractal Fern')x = [.5; .5];h = plot(x(1),x(2),'.');darkgreen = [0 2/3 0];set(h,'markersize',1,'color',darkgreen,'erasemode','none');axis([-3 3 0 10])axis offstop = uicontrol('style','toggle','string','stop', ... 'background','white');drawnowp = [ .85 .92 .99 1.00];A1 = [ .85 .04; -.04 .85]; b1 = [0; 1.6];A2 = [ .20 -.26; .23 .22]; b2 = [0; 1.6];A3 = [-.15 .28; .26 .24]; b3 = [0; .44];A4 = [ 0 0 ; 0 .16];cnt = 1;ticwhile ~get(stop,'value') r = rand; if r < p(1) x = A1*x + b1; elseif r < p(2) x = A2*x + b2; elseif r < p(3) x = A3*x + b3; else x = A4*x; end set(h,'xdata',x(1),'ydata',x(2)); drawnow cnt = cnt + 1;endt = toc;s = sprintf('%8.0f points in %6.3f seconds',cnt,t);text(-1.5,-0.5,s,'fontweight','bold');set(stop,'style','pushbutton','string','close','callback','close(gcf)')
matlab fern,fern.m 源代码在线查看 - numerical computing with matlab by matthewlewin 例子 资源下载 虫虫电子下载站...
最新推荐文章于 2021-03-24 20:06:59 发布