% Matlab code for a beautiful Fractal Fern % ... created from the IFS defined in Table III.3, pg.86 of the handout % just type "Fern" in the Matlab command window to run it clear all iterations=30000; %the number of iterations % recall, the transformations are of the form A*[x,y]+t % and, there are four such transformations ... A1=[0 0 ; 0 0.16]; A2=[0.85 0.04 ; -0.04 0.85]; A3=[0.2 -0.26 ; 0.23 0.22]; A4=[-0.15 0.28 ; 0.26 0.24]; t1=[0 ; 0]; t2=[0 ; 1.6]; t3=[0 ; 1.6]; t4=[0 ; 0.44]; % here are the probabilities with which each transformation is applied % notice that p1+p2+p3+p4=1 p1=0.01; p2=0.85; p3=0.07; p4=0.07; % the initial point x(1)=0; y(1)=0; % but, let's write the (x,y) points as a vector, v v=[0;0]; % here is the intial point for n=2:iterations % choose a random number, k, between 0 and 1 k=rand; % depending on your random number ... % do one of the four transformations to get a new point if k