Currently I am writing a MATLAB program, which generates a fractal, based off of user-defined inputs. The problem is that when I run this piece of code with large arrays it takes an enormous amount of time to process. I am looking for advice or suggestions on how to optimize this code. Any responses will be greatly appreciated.
The main program is
for j=1:1:rows
for k=1:1:rows
Z(j,k)=iter(Z(j,k),c1(j,k),niter,f1);%Z and c1 are complex number,niter is an integer f1 is a handle
end
end
The function iter is
function z=iter(z1,c,niter,f1)
for i=1:1:niter
z1=f1(z1,c);
if abs(z1)<=2
z=i;
else
z=i;
break;
end
end
end