how do i use the if statement in a for loop
1 view (last 30 days)
Show older comments
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.^n_max<10000)
n_matrix = zeros(800,800);
for n = 1:n_max
f_z = z.^n + 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')
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Line Plots 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!