Info

This question is closed. Reopen it to edit or answer.

how do i use the if statement in a for loop (corrected code)

1 view (last 30 days)
How do i use the IF statement to achieve my objective. I want the values of n for certain conditions to be output iteratively into a matrix and plotted (Julia sets)
c=-0.835 - 1i*0.232;
x=-2:0.005:2;
y=-2:0.005:2;
[X,Y]=meshgrid(x,y);
z=(X + Y*1i);
n_max=256;
b=10000; %blowup parameter. stop an iteration when |z|>b.
a=(abs(z)>=10000);
m=(z.^2)^n_max<10000)
n_matrix = zeros(800,800);
for n = 1:n_max
f_z = z.^2 + c;
z = f_z ;
if a disp(n)
if m disp (n)
end
end
end
colormap prism(256)
pcolor(n);
shading flat;
axis('square','equal','off')

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!