How can I create an array of fixed length?
Show older comments
UPDATE 1: I fixed my resolution issue, but another problem arose.
I'm currently working on a project for examining the Mandelbrot set. My goal is to draw the Mandelbrot set, center the image on a specific location, and then zoom into it. When zooming I receive the following error code:
??? Error using ==> plus
Matrix dimensions must agree.
Error in ==> drawMandelbrot at 20
z = z.^2 + z0;
When k=32, my z0 matrix goes from being 600x600 to 599x600 preventing me from zooming further because I can't add it to z.^2, which stays a constant 600x600.
_____
function [xctr,yctr] = drawMandelbrot(xmin,xmax,ymin,ymax)
res=599/(xmax-xmin);
x = xmin : 1/res : xmax;
y = ymin : 1/res : ymax;
xctr = (xmin + xmax)/2;
yctr = (ymin + ymax)/2;
Length = length(x);
[X,Y]= meshgrid(x,y);
z0 = X + i*Y;
size(z0)
z = zeros(Length,Length);
c = zeros(Length,Length);
depth = 128;
for k = 1 : depth
z = z.^2 + z0;
c(abs(z) < 2) = k;
end
c;
image(c)
axis image
drawnow
colormap(flipud(jet(depth)))
end
______
MAIN
xmin = -2.1;
xmax = .7;
ymin = -1.4;
ymax = 1.4;
[xctr,yctr] = drawMandelbrot(xmin,xmax,ymin,ymax);
xctr_new = -.75;
yctr_new = 0.1;
dx = (xctr_new - xctr)/5;
dy = (yctr_new - yctr)/5;
for j=0:4;
xmin = xmin + dx;
xmax = xmax + dx;
ymin = ymin + dy;
ymax = ymax + dy;
[xctr,yctr] = drawMandelbrot(xmin,xmax,ymin,ymax);
end
delx = (xmax - xmin)/100;
dely = (ymax - ymin)/100;
for k=0:99;
xmin = xmin + .1*k*delx;
xmax = xmax - .1*k*delx;
ymin = ymin + .1*k*dely;
ymax = ymax - .1*k*dely;
k
[xctr,yctr] = drawMandelbrot(xmin,xmax,ymin,ymax);
end
_____
Is there a way to prevent 1 row of z0 from being truncated?
Any help is much appreciated.
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!