0

I am trying to zoom into a Mandebrot set with Matlab, which is based on a meshgrid. After the first plot you can pick two points which define the zoom area and between these two points a new meshgrid is generated. This new meshgrid is the origin for the new plot. The problem now is, that the new plot is rather shapeless.

I tried this concept (zoom by calculating iterations in a narrower grid) for other julia sets, but this did not work well either. I am wondering, whether this is a completly wrong concept now.

a = 0;
func = @(x,c) x.^2 + c;
realAx = linspace(-2,1,1000);
imagAx = linspace(-1,1,1000);
[x,y] = meshgrid(realAx,imagAx);
complex = x + y*1i;

for n = 1:100
   a = func(a,complex);
end

a(abs(a) >= 2) = 0;
contour(abs(a));
[u,v] = ginput(2);

while true

while ~((u(1,1) < u(2,1)) && (v(1,1) < v(2,1)))
    [u,v] = ginput(2);
end

% Get zoom values
figure;

% Create new start coordinates
zoomX = linspace(x(round(u(1,1))),x(round(u(2,1)),1000));
zoomY = linspace(y(round(v(1,1))),y(round(v(2,1)),1000));

[x,y] = meshgrid(zoomX,zoomY);

complex = x + y*1i;
a = 0;

for n = 1:100
    a = func(a,complex);
end

a(abs(a) >= 2) = 0;   
contour(abs(a));
[u,v] = ginput(2);

end

I expect a more detailed version of the zoom area to appear. I would be really glad, if anybody had advice or would provide a different concept for zooming into the Mandelbrot set.

Amigo54
  • 5
  • 2

1 Answers1

0

I don't think you're on the wrong track. However, as @Cris Luengo said you're rounding inappropriately. Also you're duplicating code unnecessarily. Try this out

function Mandebrot

[x,y,a] = genSet([-2 1 -1 1]);

while true
    contour(x,y,abs(a));

    [x,y,a] = genSet(ginput(2));
end
end

function [x,y,a] = genSet(s)
% s is a 1x4 or 2x2 matrix

s = s(:)' ;

spanX = round( abs(diff(s(1:2))) , 1, 'significant' );
spanY = round( abs(diff(s(3:4))) , 1, 'significant' );

s(1:2) = sort(round( s(1:2) , -floor(log10(spanX)) ));
s(3:4) = sort(round( s(3:4) , -floor(log10(spanY)) ));

a = 0;
[x,y] = meshgrid( linspace( s(1) , s(2) , 1000) ,linspace( s(3) , s(4) , 1000) );
complex = x + y*1i;

for n = 1:100
    a = func(a,complex);
end

a(abs(a) >= 2) = 0;

end

function z = func(x,c)
    z = x.^2 + c;
end
user1543042
  • 3,422
  • 1
  • 17
  • 31