2

Preface on the Former Post

I had a question related to this post from 4 years ago "Coloring the Mandelbrot Set in Matlab" but I don't have enough reputation to comment directly on the post.

The code Chris Taylor provided in the post was this

function mandelbrot(n, niter)

x0 = -2;   x1 = 1;
y0 = -1.5; y1 = 1.5;
[x,y] = meshgrid(linspace(x0, x1, n), linspace(y0, y1, n));

c = x + 1i * y;
z = zeros(size(c));
k = zeros(size(c));

for ii = 1:niter
  z   = z.^2 + c;
  k(abs(z) > 2 & k == 0) = niter - ii;
end

figure,
imagesc(k),
colormap hot
axis square

The Questions

I had two to be exact:

  1. What is the matrix k for?
  2. What does the line k(abs(z) > 2 & k == 0) = niter - ii; actually mean?

Sidenotes Not Particularly Vital to the Questions

Two more quick things, first being if there is any other way to ask a question about a specific post, please let me know. I would comment on the answer itself but I don't have enough reputation to do that and I also didn't want to submit an "answer" that wasn't really an answer on that person's post. The second matter, is there any way I could just ask the author of the answer (Chris Taylor) directly what that part of his code means? If not is there a way I can tag them in this so that they can see this?

Thank you!

ApBrown
  • 35
  • 7
  • i think due to the complex mathematical nature of calculating a mandelbrot-set this question might be better off in mathematics – Gewure Apr 30 '18 at 02:23
  • `k` is the matrix that stores the color indices for the indexed color image of the fractal. The statement basically reads "All unset colors (`k == 0`) whose complex magnitude is greater than 2 (`abs(z) > 2`) are now set to the color at index `niter - ii`" – Patrick Roberts Apr 30 '18 at 03:03
  • Oh ok, that makes sense, thank you @PatrickRoberts! I'd love to accept this as the answer but you'd have to post it as such, if you could – ApBrown Apr 30 '18 at 03:05

0 Answers0