fern - [x y] = f1(x,y); elseif (num>0.85)&&(num...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function fern(n) f % function fern(n) takes in a positive integer, n, representing the number % of points of the fern to draw % axis equal off hold on h x = rand; % start from an arbitrary (x,y) y = rand; y for i = 1:n % iterate through 'n' points num = rand; % num is assigned a random number if num <= 0.85 % 85% of time, f1 computes next pt.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: [x y] = f1(x,y); elseif (num>0.85)&&(num <= 0.92)% 7% of time, f2 computes next pt. [x y] = f2(x,y); elseif (num>0.92)&&(num <=0.99) % 7% of time, f3 computes next pt. [x y] = f3(x,y); else % 1% of time, f4 computes next pt. [x y] = f4(x,y); end plot(x,y,'k') % plots fern end e...
View Full Document

This note was uploaded on 09/12/2009 for the course CS 100 taught by Professor Fan/vanloan during the Fall '07 term at Cornell University (Engineering School).

Ask a homework question - tutors are online