Sunday, October 14, 2012

Mandelbrot

Mandelbrot set plotted in Matlab



Mandelbrot set plotted in Scilab


Matlab Code:

close all;
clc;
clear all;
xmin = -0.3;
xmax = 0.1;
ymin = -1.0;
ymax = -0.6;
spacing = 1000;
x = linspace(xmin,xmax,spacing);
y = linspace(ymin,ymax,spacing);
[X,Y] = meshgrid(x,y);
Z = X + 1i*Y;
maxIter = 500;
c = ones(size(Z));
C = Z;
for n = 1:maxIter
Z = Z.^2 + C;
mag = abs(Z) <=2;
c = c + mag; 
end
surfc(X,Y,c);
shading interp

No comments :

Post a Comment