MATLAB: How to go back to check condition again after the if-else statement

if else

This is my coding,
cond=exp(z(2)*(1-z(1)))-(1/z(3));
if cond<0
h=@test;
znew=simulannealbnd(h,z,[0 0 0],[1.0 10.0 1.0],options)
else
r1 = a1 + (b1-a1).*rand(1,1);
r2= a2 + (b2-a2).*rand(1,1);
r3= a3 + (b3-a3).*rand(1,1);
z=[r1 r2 r3];
end
After getting the z=[r1 r2 r3], i want to go back to check the condition again. How to write the code?

Best Answer

test=0;
while test==0
cond=exp(z(2)*(1-z(1)))-(1/z(3));
if cond<0
h=@test;
znew=simulannealbnd(h,z,[0 0 0],[1.0 10.0 1.0],options)
test=1;
else
r1 = a1 + (b1-a1).*rand(1,1);
r2= a2 + (b2-a2).*rand(1,1);
r3= a3 + (b3-a3).*rand(1,1);
z=[r1 r2 r3];
test=0;
end
end
Related Question