if i want to stop infinite while loop after 30 iteration, so how can i use it in my matlab code?
Show older comments
if i want to stop infinite while loop after 30 iteration, so how can i use it in my matlab code?
Accepted Answer
More Answers (1)
Azzi Abdelmalek
on 11 Feb 2013
Edited: Azzi Abdelmalek
on 11 Feb 2013
test=0
while condition & test<=30
%your code
test=test+1
end
3 Comments
swati chauhan
on 11 Feb 2013
Image Analyst
on 11 Feb 2013
Edited: Image Analyst
on 11 Feb 2013
It's good to avoid infinite loops. You should always have a failsafe in there, like bail out if the number of iterations exceeds some number that you know is abnormally high, which means something went wrong. Otherwise it's possible for your program to hang the computer.
swati chauhan
on 12 Feb 2013
Categories
Find more on Image Arithmetic 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!