function inValues= mndl(limits) %no inputs needed, used by the script to zoom in
%amount of detail to calculate; larger number = better resolution, slower calculation stepsR=300; stepsI=300;
%maximum iterations used in calculations maxIter=50;
if exist('limits')~=1; %intial range of real and imaginary numbers to compute lowerR=-2; lowerI=-1.25; higherR=1; higherI=1.25; else numel(limits)==4; %range to compute after zooming in, determined by axis lowerR=limits(1); lowerI=limits(3); higherR=limits(2); higherI=limits(4); end
%Constants: slR=(higherR-lowerR)/(stepsR-1); slI=(higherI-lowerI)/(stepsI-1);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Create the Mandelbrot image.
[x,y]=meshgrid([0:stepsR-1]slR+lowerR,[0:stepsI-1]slI+lowerI); inValues=ones(size(x)); z=zeros(size(x)); c=(x+1iy);
h_z=1:(stepsRstepsI); for counter=1:maxIter z(h_z)=z(h_z).^2+c(h_z); h_z= h_z(abs(z(h_z))<2); inValues(h_z)=inValues(h_z)+1; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%format presentation of Mandelbrot image colormap jet; pcolor(x,y,log(double(inValues))); title('Mandelbrot Image: Zoom In and Sharpen for Details'); shading interp; axis off;
zoom %turn on zoom feature initially clear inValues
%Buttons:
%recalculate image to enhance after zooming in (just calls the function %again with new input argument based on current axis) h1= uicontrol('Parent',gcf,'Units','points', ... 'Callback',['mndl(axis);zoom;'], ... 'Position',[105 5 105 20],'Style','pushbutton','String','Sharpen (after zooming in)');
%turn the zoom button on or off h2= uicontrol('Parent',gcf,'Units','points', ... 'Callback',['zoom'], ... 'Position',[215 5 55 20],'Style','pushbutton','String','Zoom On/Off');
%reset the image h3= uicontrol('Parent',gcf,'Units','points', ... 'Callback',['mndl();zoom;'], ... 'Position',[275 5 40 20],'Style','pushbutton','String','Reset');