the endless while loop how do i avoid it
Mostra commenti meno recenti
I have the code below for julia sets. it is supposed to run for less than 3 minutes. However it has kept the computer busy for over 30 mins, i had to stop it with task manager.
How do i stop this endless loop and get a result.
c=-0.835 - 1i*0.232;
x=-2:0.008:2;
y=-2:0.008:2;
[X,Y]=meshgrid(x,y);
f=z.^2+c;
n_max=256;
b=10000; %threshold. stop an iteration when |z|==b.
z=(X + Y*1i);
M=zeros(500,500);
for d = 1:500
for e=1:500
n=0;
while n<n_max & abs(z)<b
z=z.^2+c;
n=n+1;
end
if abs(z)<b
M(d,e)=n;
end
end
end
colormap prism(256)
image([-2 -2], [-2 -2],M);
colorbar;
axis xy
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Startup and Shutdown in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!