• Remix
  • Share
  • New Entry

on 6 Nov 2023
  • 8
  • 40
  • 0
  • 1
  • 595
drawframe(1);
Write your drawframe function below
function drawframe(f)
%Code from:
%https://www.mathworks.com/help/parallel-computing/illustrating-three-approaches-to-gpu-computing-the-mandelbrot-set.html
persistent fig
if isempty(fig)
maxIterations = 500;
gridSize = 1750;
xlim = [-0.748766713922161, -0.748766707771757];
ylim = [ 0.123640844894862, 0.123640851045266];
x = linspace(xlim(1),xlim(2),gridSize);
y = linspace(ylim(1),ylim(2),gridSize);
[xGrid,yGrid] = meshgrid(x,y);
z0 = xGrid + 1i*yGrid;
z = z0;
cpuCount = 0;
for n = 0:maxIterations
z = z.*z + z0;
inside = abs(z)<=2;
cpuCount = cpuCount + inside;
end
cpuCount = log(cpuCount);
fig = figure;
imagesc(x,y,cpuCount);
c = colormap([jet;flipud(jet);0 0 0]);
axis off
return
end
zoomFactor = 1.04;
zoom(fig,zoomFactor)
title(['Current Zoom = ',num2str(round(zoomFactor^(f-1),2))])
end
Animation
Remix Tree