matlab - Plot black and white mandelbrot set -


below code taken here.

i trying make following change code below

if c not part of set, plot white pixel, , if part of set, plot black pixel.

i getting output: enter image description here

but want plot black , white mandelbrot image this:

enter image description here

use imshow command plot image

can ?

    m=601;      n=401;     count_max = 200;    %change range of x's , y's here    x_max =   1;   x_min = - 2;   y_max =   1;   y_min = - 1;  % %  create array of complex sample points in [x_min,x_max] + [y_min,y_max]*i. %   = ( 1 : m );   j = ( 1 : n );   x = ( ( - 1 ) * x_max + ( m - ) * x_min ) / ( m - 1 );   y = ( ( j - 1 ) * y_max + ( n - j ) * y_min ) / ( n - 1 );   [ zr, zi ] = meshgrid ( x, y );   c = complex ( zr, zi ); % %  carry out iteration. %   epsilon = 0.001;    z = c;   ieps = 1 : numel ( c );    %iterate through 1 maximum no. of iterations   = 1 : count_max     z(ieps) = z(ieps) .* z(ieps) + c(ieps);      w(ieps) = exp ( - abs ( z(ieps) ) );     ieps = ieps ( find ( epsilon < w(ieps) ) );   end % %  display data. %   d = log ( abs ( z ) );   t = delaunay ( zr, zi ); % %  see individual pixels, use 'flat' color. %  h = trisurf ( t, zr, zi, d, 'facecolor', 'flat', 'edgecolor', 'flat' ); %  h = trisurf ( t, zr, zi, d, 'facecolor', 'interp', 'edgecolor', 'interp' );    view ( 2 )   axis equal   axis on   title_string = sprintf ( 'mandelbrot set, %d x %d pixels, %d iterations', ...     m, n, count_max );   title ( title_string )   xlabel ('real axis');   ylabel ('imaginary axis'); %  terminate. 

the difference of belonging set , not belonging set nothing else epsilon < w(ieps) , using in code. colorinformation in plot coming fourth argument of trisurf ( t, zr, zi, d,...).

so suggest following before trisurf command:

d(1 : numel ( c )) = 1; d(ieps) = 0; 

this first sets elements 1 , sets elements 0 part of set, according condition calculated in last iteration of convergence test.

to plot black , white, use colormap gray after trisurf.

hope helps.


Comments

Popular posts from this blog

Why does Go error when trying to marshal this JSON? -

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

apache - Restler setup not working -