如何通过计算更多点来使用 Matlab 放大 Mandebrot 集?

How to zoom into a Mandebrot set with Matlab by calculating more points?

我正在尝试使用基于网格的 Matlab 放大 Mandebrot 集。在第一个绘图之后,您可以选择定义缩放区域的两个点,并在这两点之间生成一个新的网格。这个新的网格是新情节的起源。现在的问题是,新剧情有点乱

我为其他 julia 集尝试了这个概念(通过在较窄的网格中计算迭代来缩放),但这也不太奏效。 我想知道,现在这是否是一个完全错误的概念。

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

我希望出现更详细的缩放区域版本。 如果有人有建议或提供不同的概念来放大 Mandelbrot 集,我将非常高兴。

我不认为你走错了路。但是,正如@Cris Luengo 所说,您四舍五入不当。此外,您还在不必要地复制代码。试试这个

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