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

2 views (last 30 days)
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?

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 21 Aug 2013
Edited: Azzi Abdelmalek on 21 Aug 2013
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

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!