Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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?

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 21 Ago 2013
Modificato: Azzi Abdelmalek il 21 Ago 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

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by