Mandelbrot set escape value is complex?
Show older comments
My codes are as follows,
clear all, clc
[re,im] = meshgrid(-3:0.5:3,-3:0.5:2); % create a 2D grid ranging from -5 to 5 in both x and y
c = re+ j*im; % turn the c value into complex values.
row = size(c,1); % gives the row dimension of the matrix
column = size(c,2); % gives the column dimension of the matrix
k=0;
Lmat = zeros(row,column); % a zero matrix that stores the lastval
% The nested for loop here prints the value of each
for i = 1:1:row
for j = 1:1:column
cval = c(i,j);
k = k+1;
% Run the iteration loop here
zn = 0;
iteration = 0; % i stands for iteration
n = 10;
while iteration <(n+1) % (n + 1) to denote the number of iterations
zn = (zn)*(zn')+cval;
lastval = zn;
iteration = iteration+1;
%fprintf('Iteration #%5.0f.lastval: %4.5f\n',iteration,lastval)
if iteration == n+1
%fprintf('loop ended.\n')
break
end
Lmat(i,j) = lastval;
end
% Lmat(i,j) = lastval;
% fprintf('j=%3.0f.\n',j)
end
% fprintf('i=%3.0f.\n',i)
end
surf(re,im,real(Lmat))
And when I generated the plot it just doesn't look like what it's supposed to.
Is the escape value supposed to be complex? I think it should? because escapevalue = zn*zn' + cval and cval by itself is complex. and therefore the cval alone has a contribution to the escape value.
I am also thinking that my mathematical logic in this code is simply incorrect. Since I attempted to plot every cval, but I thought the purpose of mandelbrot set is to test out which cval can escape and which cval cannot escape.
Please if you could let me know where I got it wrong I would greatly appreciate it!
Thanks,
Michael.
2 Comments
Plotting the positions of the poiunt over the iterations is the Julia set, not the Mandelbrot set. For the Mandelbrot set count the number of iterations you need to leave a radius of 2.
Why do you use 2 stopping methods to limit the loop?
while iteration <(n+1)
...
if iteration == n+1
Michael Lam
on 19 Mar 2022
Edited: Michael Lam
on 19 Mar 2022
Accepted Answer
More Answers (0)
Categories
Find more on Fractals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!