How to go back to check condition again after the if-else statement
2 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
Azzi Abdelmalek
2013-8-21
编辑:Azzi Abdelmalek
2013-8-21
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
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Outputs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!