function mandelplot(edge,x1,x2,y1,y2) %mandelplot(edge,x1,x2,y1,y2) generates a plot of part of the Mandelbrot set % edge is the number of points along each edge of the graph (maximum 127 in Student Edition MATLAB) % [x1,x2] are min and max x values which are checked,(between -4 and 1) % [y1,y2] are min and max y values which are checked, (between -2.25 and 2.25) % Note that the Student Edition of MATLAB is limited to a 127x127 array % Try calling '[m]=mandelbrot(100,-2,-1.9,.5,.6) or use mandelplot(edge,x1,x2,y1,y2) % MD Checkel 990103 x=[x1:(x2-x1)/edge:x2]; %create array of x positions y=[y1:(y2-y1)/edge:y2]; %create array of y positions m=zeros(edge); %create mandelbrot array, m m=mandelbrot(edge,x1,x2,y1,y2); %use mandelbrot function to fill mandelbrot array clf;surf(x,y,m) %clear screen and create a 3-d surface plot of array m %these commands make the output look prettier axis tight; %minimize the white space around the plot shading interp; map=colormap; %use interpolated shading. load default colour map map(1,3)=0; %adjust the lowest value in map to be black colormap(map); %apply modified colour map to the surface plot view(2) %view as a 2-d contour map %give the user a chance to change viewpoint, etc. disp('******************************************************') disp('MANDELPLOT') % first warn what you are doing disp('Present Viewpoint is 2d, ie view(2) or view(0,90)') disp(' ') disp('Change viewpoint using view(3) or view(azimuth,elevation)') disp(' ') disp('Type return to get back to MATLAB window') keyboard %then give keyboard control to user