how to run a function again and again till a condition satisfies?
3 views (last 30 days)
Show older comments
Hello, i have a function which i want to run again and again till the condition is fulfilled.
please please help me....
0 Comments
Accepted Answer
Mischa Kim
on 27 Apr 2015
suchismita, see e.g.,
flag = false;
cnt = 0;
while ~flag
cnt = cnt + 1;
fprintf('Try no.: %d\n', cnt);
if (rand() < 0.25)
flag = true;
end
end
Your function would simply reside inside the loop.
See Also
Categories
Find more on Loops and Conditional Statements 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!